From 8ad45f7a9ae97cc951db4bed1c304a476013c8a0 Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Thu, 28 Jan 2010 07:19:32 +0100
Subject: [PATCH 01/10] Preserve ./configure --help order.

Since we used AC_ARG_WITH(groupname) to indicate a group of options we
definitely want the configure output sorted.
Now we use EXTEND_HELP_STRING and do no longer abuse AC_ARG_WITH.

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index e7ee60b..bc6ed1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,6 +21,7 @@ AC_CONFIG_MACRO_DIR(m4)
 AC_CONFIG_LIBOBJ_DIR(compat)
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
+AC_PRESERVE_HELP_ORDER
 
 AM_INIT_AUTOMAKE(tar-ustar)
 AM_CONFIG_HEADER(config.h)
@@ -80,6 +81,11 @@ AC_C_CONST
 AC_C_INLINE
 AC_C_RESTRICT
 
+dnl Extend the --help string at the current spot.
+AC_DEFUN([EXTEND_HELP_STRING],
+[m4_divert_once([HELP_ENABLE], [$1])dnl
+])
+
 dnl Allow binary package maintainer to pass a custom string to avoid
 dnl cache problem
 AC_ARG_WITH(binary-version,
@@ -1145,8 +1151,8 @@ fi
 dnl
 dnl  Accelerated modules
 dnl
-AC_ARG_WITH(,[])
-AC_ARG_WITH(,[Optimization options:])
+EXTEND_HELP_STRING([])
+EXTEND_HELP_STRING([Optimization options:])
 
 dnl  Check for fully working MMX intrinsics
 dnl  We need support for -mmmx, we need <mmintrin.h>, and we also need a
@@ -1704,7 +1710,7 @@ dnl
 dnl  Input plugins
 dnl
 
-AC_ARG_WITH(,[Input plugins:])
+EXTEND_HELP_STRING([Input plugins:])
 
 dnl  live555 input
 dnl
@@ -2518,7 +2524,7 @@ dnl
 dnl  Codec plugins
 dnl
 
-AC_ARG_WITH(,[Codec plugins:])
+EXTEND_HELP_STRING([Codec plugins:])
 
 dnl
 dnl wmafixed plugin
@@ -3208,7 +3214,7 @@ dnl
 dnl  Video plugins
 dnl
 
-AC_ARG_WITH(,[Video plugins:])
+EXTEND_HELP_STRING([Video plugins:])
 
 dnl
 dnl  Xlib
@@ -3650,7 +3656,7 @@ dnl
 dnl  Audio plugins
 dnl
 
-AC_ARG_WITH(,[Audio plugins:])
+EXTEND_HELP_STRING([Audio plugins:])
 
 dnl
 dnl  OSS /dev/dsp module (enabled by default except on win32)
@@ -3817,7 +3823,7 @@ dnl
 dnl  Interface plugins
 dnl
 
-AC_ARG_WITH(,[Interface plugins:])
+EXTEND_HELP_STRING([Interface plugins:])
 
 dnl
 dnl Skins2 module
@@ -4110,8 +4116,7 @@ AS_IF([VLC_FEATURE_ENABLED([lirc])], [
   fi
 ])
 
-
-AC_ARG_WITH(,[Misc options:])
+EXTEND_HELP_STRING([Misc options:])
 
 dnl
 dnl libgcrypt
@@ -4290,7 +4295,7 @@ AS_IF([VLC_FEATURE_ENABLED([loader])],
     VLC_ADD_LIBS([dmo quicktime], [-lpthread])
   ])
 
-AC_ARG_WITH(,[Components:])
+EXTEND_HELP_STRING([Components:])
 
 dnl
 dnl  the VLC binary
-- 
1.6.6.1


From c270d905f5c104fa40fd35d13d7fe169a7ef4624 Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Thu, 28 Jan 2010 08:09:05 +0100
Subject: [PATCH 02/10] Provide abstraction for string options to configure.

Because we now only take --with-* for string passing:
--with-a52-fixed became --enable-a52-fixed
--with-contrib became --enable-contrib
a52-fixed had a bug where with --without-a52-fixed would result in a
false positive.
--without-foo is still possible (as it just sets the argument to "no")
but it will print a notice during configure, saying that it's either a
really uncommon string to pass to configure, or that the user made a
mistake by thinking --without-foo disables something.

Also remove the special mozilla_sdk_xpcom handling for mingw, it was
removed in 11390074753cc36741787113e7ee11324315f4ac.

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac       |  509 +++++++++++++++++++++++-----------------------------
 m4/vlc_features.m4 |   95 ++++++++++-
 2 files changed, 316 insertions(+), 288 deletions(-)

diff --git a/configure.ac b/configure.ac
index bc6ed1c..94753d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,11 +88,9 @@ AC_DEFUN([EXTEND_HELP_STRING],
 
 dnl Allow binary package maintainer to pass a custom string to avoid
 dnl cache problem
-AC_ARG_WITH(binary-version,
-	AS_HELP_STRING([--with-binary-version=STRING],
-	     [To avoid plugins cache problem between binary version]),[],[])
-AS_IF([test -n "${with_binary_version}"],[
-      AC_DEFINE_UNQUOTED([DISTRO_VERSION],["${with_binary_version}"],
+VLC_STRING_OPTION([binary-version], [To avoid plugins cache problem between binary version], [STRING])
+AS_IF([VLC_STRING_SET([binary-version])], [
+      AC_DEFINE_UNQUOTED([DISTRO_VERSION],["${vlc_string_binary_version}"],
 			 [Binary specific version])
       ])
 
@@ -100,9 +98,8 @@ AS_IF([test -n "${with_binary_version}"],[
 dnl
 dnl  Check for the contrib directory
 dnl
-AC_ARG_WITH(contrib,
-    [  --without-contrib       do not use the libraries in CONTRIB_DIR],[],[])
-  AS_IF([test "${with_contrib}" != "no"],[
+VLC_FEATURE_OPTION([contrib], [use the libraries in CONTRIB_DIR], [enabled])
+AS_IF([VLC_FEATURE_ENABLED([contrib])], [
     AC_ARG_VAR([CONTRIB_DIR], [directory containing pre-built contrib, overriding extras/contrib])
     if test -z "$CONTRIB_DIR"
     then
@@ -138,12 +135,7 @@ AC_ARG_WITH(contrib,
     LDFLAGS="${LDFLAGS} -L${CONTRIB_DIR}/lib"
     LDFLAGS_save="${LDFLAGS_save} -L${CONTRIB_DIR}/lib"
 
-    if test -z $with_mozilla_sdk_path; then
-       with_mozilla_sdk_path=${CONTRIB_DIR}/gecko-sdk
-    fi
-    if test -z $with_cyberlink_tree; then
-       with_cyberlink_tree=${CONTRIB_DIR}/src/clinkcc
-    fi
+    have_contrib_libs="yes"
 
     if test "${SYS}" = "darwin"; then
       export LD_LIBRARY_PATH=${CONTRIB_DIR}/lib:$LD_LIBRARY_PATH
@@ -210,10 +202,8 @@ case "${host_os}" in
     AS_IF([VLC_FEATURE_ENABLED([macosx-defaults])], [
         echo ""
         echo "Building with Mac OS X defaults:"
-        with_macosx_version_min="10.5"
-        echo "  Assuming --with-macosx-version-min=10.5"
-        with_macosx_sdk="/Developer/SDKs/MacOSX${with_macosx_version_min}.sdk"
-        echo "  Assuming --with-macosx-sdk=/Developer/SDKs/MacOSX${with_macosx_version_min}.sdk"
+        VLC_STRING_FORCE([macosx-version-min], [10.5])
+        VLC_STRING_FORCE([macosx-sdk], [/Developer/SDKs/MacOSX10.5.sdk])
         build_dir=`pwd`
         echo "  Assuming --prefix=${build_dir}/vlc_install_dir"
         ac_default_prefix="${build_dir}/vlc_install_dir"
@@ -235,29 +225,27 @@ case "${host_os}" in
     dnl
     dnl  Check for Mac OS X SDK settings
     dnl
-    AC_ARG_WITH(macosx-sdk,
-       [  --with-macosx-sdk=DIR   compile using the SDK in DIR])
-    if test "${with_macosx_sdk}" != "" ; then
-        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}"
-    fi
-    AC_ARG_WITH(macosx-version-min,
-       [  --with-macosx-version-min=VERSION compile for MacOSX 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}
+    VLC_STRING_OPTION([macosx-sdk], [compile using the SDK in DIR], [DIR])
+    AS_IF([VLC_STRING_SET([macosx-sdk])], [
+        CPP="${CPP} -isysroot ${vlc_string_macosx_sdk}"
+        CC="${CC} -isysroot ${vlc_string_macosx_sdk}"
+        CXX="${CXX} -isysroot ${vlc_string_macosx_sdk}"
+        OBJC="${OBJC} -isysroot ${vlc_string_macosx_sdk}"
+        LD="${LD} -syslibroot ${vlc_string_macosx_sdk}"
+    ])
+    VLC_STRING_OPTION([macosx-version-min], [compile for MacOSX VERSION and above], [VERSION])
+    AS_IF([VLC_STRING_SET([macosx-sdk])], [
+        CPP="${CPP} -mmacosx-version-min=${vlc_string_macosx_version_min}"
+        CC="${CC} -mmacosx-version-min=${vlc_string_macosx_version_min}"
+        CXX="${CXX} -mmacosx-version-min=${vlc_string_macosx_version_min}"
+        OBJC="${OBJC} -mmacosx-version-min=${vlc_string_macosx_version_min}"
+        LD="${LD} -macosx_version_min=${vlc_string_macosx_version_min}"
+        CFLAGS_save="${CFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}"; CFLAGS="${CFLAGS_save}"
+        CXXFLAGS_save="${CXXFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}"; CXXFLAGS="${CXXFLAGS_save}"
+        OBJCFLAGS_save="${OBJCFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}"; OBJCFLAGS="${OBJCFLAGS_save}"
+        MACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}
         export MACOSX_DEPLOYMENT_TARGET
-    fi
+    ])
     ;;
   darwin9*)
     if test "${host_cpu}" = "i386"; then
@@ -1474,14 +1462,12 @@ AM_CONDITIONAL([HAVE_ALTIVEC], [test "$have_altivec" = "yes"])
 dnl
 dnl  Special arch tuning
 dnl
-AC_ARG_WITH(tuning,
-[  --with-tuning=ARCH      enable special tuning for an architecture
-                          (default Pentium 2 on IA-32 and G4 on PPC)])
-if test -n "${with_tuning}"; then
-    if test "${with_tuning}" != "no"; then
-        CFLAGS_TUNING="-mtune=${with_tuning}"
-    fi
-else
+VLC_STRING_OPTION([tuning], [enable special tuning for an architecture], [ARCH], [
+  Pentium 2 on IA-32 and G4 on PPC
+])
+AS_IF([VLC_STRING_SET([tuning])], [
+    CFLAGS_TUNING="-mtune=${vlc_string_tuning}"
+], [
     if test "${SYS}" = "darwin" -a "${host_cpu}" != "powerpc"; then
         CFLAGS_TUNING="-march=prescott -mtune=generic"
     elif test "${host_cpu}" = "i686" -o "${host_cpu}" = "i586" -o "${host_cpu}" = "i486" -o "${host_cpu}" = "i386"; then
@@ -1491,7 +1477,7 @@ else
     elif test "${host_cpu}" = "powerpc"; then
         CFLAGS_TUNING="-mtune=G4";
     fi
-fi
+])
 
 dnl NOTE: this can't be cached cleanly
 AS_IF([test "${CFLAGS_TUNING}"],
@@ -1502,7 +1488,7 @@ AS_IF([test "${CFLAGS_TUNING}"],
     AC_COMPILE_IFELSE([ ],
                       [tuning="yes"],
                       [CFLAGS_TUNING=""; tuning="no"
-                       AS_IF([test "${with_tuning}"],
+                       AS_IF([VLC_STRING_SET([with-tuning])],
                              [AC_MSG_ERROR([requested tuning not supported])])])
 
     AC_MSG_RESULT([$tuning])
@@ -1716,13 +1702,12 @@ dnl  live555 input
 dnl
 VLC_FEATURE_OPTION([live555], [live555 RTSP input plugin])
 AS_IF([VLC_FEATURE_ENABLED([live555])], [
-  AC_ARG_WITH(live555-tree,
-    [  --with-live555-tree=PATH live.com tree for static linking])
+  VLC_STRING_OPTION([live555-tree], [live.com tree for static linking], [PATH])
 
   dnl
   dnl test for --with-live555-tree
   dnl
-  if test -z "${with_live555_tree}" -a "${CXX}" != ""; then
+  AS_IF([{ VLC_STRING_UNSET([live555-tree]) && test "${CXX}" != "" ;}], [
     AC_LANG_PUSH(C++)
     CPPFLAGS_save="${CPPFLAGS}"
     CPPFLAGS_live555="-I/usr/include/liveMedia -I/usr/include/groupsock -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment"
@@ -1774,12 +1759,12 @@ lternatively you can use --disable-live555 to disable the liveMedia plugin.])
     CPPFLAGS="${CPPFLAGS_save}"
     AC_LANG_POP(C++)
   else
-    AC_MSG_CHECKING(for liveMedia/libliveMedia.a in ${with_live555_tree})
-    real_live555_tree="`cd ${with_live555_tree} 2>/dev/null && pwd`"
+    AC_MSG_CHECKING(for liveMedia/libliveMedia.a in ${vlc_string_live555_tree})
+    real_live555_tree="`cd ${vlc_string_live555_tree} 2>/dev/null && pwd`"
     if test -z "${real_live555_tree}"; then
       dnl  The given directory can't be found
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot cd to ${with_live555_tree}])
+      AC_MSG_ERROR([cannot cd to ${vlc_string_live555_tree}])
     fi
     if test -f "${real_live555_tree}/liveMedia/libliveMedia.a"; then
       AC_MSG_RESULT(${real_live555_tree}/liveMedia/libliveMedia.a)
@@ -1824,10 +1809,10 @@ lternatively you can use --disable-live555 to disable the liveMedia plugin.])
       dnl  The given live555 wasn't built
         AC_MSG_RESULT(no)
       AS_IF([VLC_FEATURE_REQUESTED([live555])], [
-        AC_MSG_ERROR([cannot find ${real_live555_tree}/liveMedia/libliveMedia.a, make sure you compiled live555 in ${with_live555_tree}])
+        AC_MSG_ERROR([cannot find ${real_live555_tree}/liveMedia/libliveMedia.a, make sure you compiled live555 in ${vlc_string_live555_tree}])
       ])
     fi
-  fi
+  ])
 ])
 
 dnl
@@ -1842,20 +1827,16 @@ dnl dvdread module: check for libdvdread
 dnl
 VLC_FEATURE_OPTION([dvdread], [dvdread input module])
 AS_IF([VLC_FEATURE_ENABLED([dvdread])], [
-  AC_ARG_WITH(dvdread,
-  [  --with-dvdread=PATH     libdvdread headers and libraries])
-  AC_ARG_WITH(dvdread-tree,
-  [  --with-dvdread-tree=PATH libdvdread tree for static linking])
+  VLC_STRING_OPTION([dvdread], [libdvdread headers and libraries], [PATH])
+  VLC_STRING_OPTION([dvdread-tree], [libdvdread tree for static linking], [PATH])
 
   dnl Temporary hack (yeah, sure ;)
   if test "${SYS}" = "mingw32" || test "${SYS}" = "darwin" || test "${SYS}" = "beos" ; then
       VLC_ADD_LIBS([dvdread],[-ldvdcss])
   fi
 
-  if test -z "${with_dvdread}"
-  then
-    if test -z "${with_dvdread_tree}"
-    then
+  AS_IF([VLC_STRING_UNSET([dvdread])], [
+    AS_IF([VLC_STRING_UNSET([dvdread-tree])], [
       AC_CHECK_HEADERS(dvdread/dvd_reader.h,
         [ VLC_ADD_PLUGIN([dvdread])
           VLC_ADD_LIBS([dvdread],[-ldvdread ${LIBS_dvdcss}])
@@ -1869,14 +1850,14 @@ AS_IF([VLC_FEATURE_ENABLED([dvdread])], [
 	     ])
 	   ])
 	])
-    else
-      AC_MSG_CHECKING(for libdvdread.a in ${with_dvdread_tree})
-      real_dvdread_tree="`cd ${with_dvdread_tree} 2>/dev/null && pwd`"
+    ], [
+      AC_MSG_CHECKING(for libdvdread.a in ${vlc_string_dvdread_tree})
+      real_dvdread_tree="`cd ${vlc_string_dvdread_tree} 2>/dev/null && pwd`"
       if test -z "${real_dvdread_tree}"
       then
         dnl  The given directory can't be found
         AC_MSG_RESULT(no)
-        AC_MSG_ERROR([cannot cd to ${with_dvdread_tree}])
+        AC_MSG_ERROR([cannot cd to ${vlc_string_dvdread_tree}])
       fi
       if test -f "${real_dvdread_tree}/dvdread/.libs/libdvdread.a"
       then
@@ -1888,24 +1869,24 @@ AS_IF([VLC_FEATURE_ENABLED([dvdread])], [
       else
         dnl  The given libdvdread wasn't built
         AC_MSG_RESULT(no)
-        AC_MSG_ERROR([cannot find ${real_dvdread_tree}/dvdread/.libs/libdvdread.a, make sure you compiled libdvdread in ${with_dvdread_tree}])
+        AC_MSG_ERROR([cannot find ${real_dvdread_tree}/dvdread/.libs/libdvdread.a, make sure you compiled libdvdread in ${vlc_string_dvdread_tree}])
       fi
-    fi
-  else
-    AC_MSG_CHECKING(for dvdread headers in ${with_dvdread})
-    if test -f ${with_dvdread}/include/dvdread/dvd_reader.h
+    ])
+  ], [
+    AC_MSG_CHECKING(for dvdread headers in ${vlc_string_dvdread})
+    if test -f ${vlc_string_dvdread}/include/dvdread/dvd_reader.h
     then
-      dnl  Use ${with_dvdread}/include/dvdread/dvd_reader.h
+      dnl  Use ${vlc_string_dvdread}/include/dvdread/dvd_reader.h
       AC_MSG_RESULT(yes)
       VLC_ADD_PLUGIN([dvdread])
-      VLC_ADD_LIBS([dvdread],[-L${with_dvdread}/lib -ldvdread ${LIBS_dvdcss}])
-      VLC_ADD_CPPFLAGS([dvdread],[-I${with_dvdread}/include])
+      VLC_ADD_LIBS([dvdread],[-L${vlc_string_dvdread}/lib -ldvdread ${LIBS_dvdcss}])
+      VLC_ADD_CPPFLAGS([dvdread],[-I${vlc_string_dvdread}/include])
     else
       dnl  No libdvdread could be found, sorry
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot find ${with_dvdread}/include/dvdread/dvd_reader.h])
+      AC_MSG_ERROR([cannot find ${vlc_string_dvdread}/include/dvdread/dvd_reader.h])
     fi
-  fi
+  ])
 ])
 
 dnl
@@ -1919,13 +1900,11 @@ AS_IF([VLC_FEATURE_ENABLED([dvdnav])], [
   fi
 
   DVDNAV_PATH="${PATH}"
-  AC_ARG_WITH(dvdnav-config-path,
-    [  --with-dvdnav-config-path=PATH dvdnav-config path (default search in \$PATH)],
-    [ if test "${with_dvdnav_config_path}" != "no"
-      then
-        DVDNAV_PATH="${with_dvdnav_config_path}:${PATH}"
-      fi ])
-  AC_PATH_PROG(DVDNAV_CONFIG, dvdnav-config, no, ${DVDNAV_PATH})
+  VLC_STRING_OPTION([dvdnav-config-path], [dvdnav-config path], [PATH], [search in \$PATH])
+  AS_IF([VLC_STRING_SET([dvdnav-config-path])], [
+    DVDNAV_PATH="${vlc_string_dvdnav_config_path}:${PATH}"
+  ])
+  AC_PATH_PROG(DVDNAV_CONFIG, dvdnav-config, no, [${DVDNAV_PATH}])
   if test "${DVDNAV_CONFIG}" != "no"
   then
     VLC_ADD_PLUGIN([dvdnav])
@@ -1967,28 +1946,29 @@ dnl  OpenCV wrapper and example filters
 dnl
 VLC_FEATURE_OPTION([opencv], [OpenCV (computer vision) filter], [disabled])
 AS_IF([VLC_FEATURE_ENABLED([opencv]) && test "${CXX}" != ""], [
-  AC_ARG_WITH(opencv-tree,
-  [  --with-opencv-tree=PATH opencv tree for linking])
+  VLC_STRING_OPTION([opencv-tree], [opencv tree for linking], [PATH])
     if test "${SYS}" = "mingw32"
     then
-      test -z "${with_opencv_tree}" && AC_MSG_ERROR([You have to specify --with-opencv-tree])
-      AC_MSG_CHECKING(for opencv in ${with_opencv_tree})
-      if test -f ${with_opencv_tree}/cv/include/cv.h -a -f ${with_opencv_tree}/cxcore/include/cxcore.h \
-        -a -f ${with_opencv_tree}/cvaux/include/cvaux.h -a -f ${with_opencv_tree}/otherlibs/highgui/highgui.h
+      AS_IF([VLC_STRING_UNSET([opencv-tree])], [
+        AC_MSG_ERROR([You have to specify --with-opencv-tree])
+      ])
+      AC_MSG_CHECKING(for opencv in ${vlc_string_opencv_tree})
+      if test -f ${vlc_string_opencv_tree}/cv/include/cv.h -a -f ${vlc_string_opencv_tree}/cxcore/include/cxcore.h \
+        -a -f ${vlc_string_opencv_tree}/cvaux/include/cvaux.h -a -f ${vlc_string_opencv_tree}/otherlibs/highgui/highgui.h
       then
         AC_MSG_RESULT(yes)
         VLC_ADD_PLUGIN([opencv_wrapper])
-        VLC_ADD_LIBS([opencv_wrapper],[-L${with_opencv_tree}/lib -lcv -lcxcore -lcvaux -lhighgui])
-        VLC_ADD_CFLAGS([opencv_wrapper],[-I${with_opencv_tree}/cv/include -I${with_opencv_tree}/cxcore/include -I${with_opencv_tree}/cvaux/include -I${with_opencv_tree}/otherlibs/highgui])
+        VLC_ADD_LIBS([opencv_wrapper],[-L${vlc_string_opencv_tree}/lib -lcv -lcxcore -lcvaux -lhighgui])
+        VLC_ADD_CFLAGS([opencv_wrapper],[-I${vlc_string_opencv_tree}/cv/include -I${vlc_string_opencv_tree}/cxcore/include -I${vlc_string_opencv_tree}/cvaux/include -I${vlc_string_opencv_tree}/otherlibs/highgui])
         AC_LANG_PUSH(C++)
         VLC_ADD_PLUGIN([opencv_example])
-        VLC_ADD_LIBS([opencv_example],[-L${with_opencv_tree}/lib -lcv -lcxcore -lcvaux -lhighgui])
-        VLC_ADD_CXXFLAGS([opencv_example],[-I${with_opencv_tree}/cv/include -I${with_opencv_tree}/cxcore/include -I${with_opencv_tree}/cvaux/include -I${with_opencv_tree}/otherlibs/highgui])
+        VLC_ADD_LIBS([opencv_example],[-L${vlc_string_opencv_tree}/lib -lcv -lcxcore -lcvaux -lhighgui])
+        VLC_ADD_CXXFLAGS([opencv_example],[-I${vlc_string_opencv_tree}/cv/include -I${vlc_string_opencv_tree}/cxcore/include -I${vlc_string_opencv_tree}/cvaux/include -I${vlc_string_opencv_tree}/otherlibs/highgui])
         AC_LANG_POP(C++)
       else
         dnl  No opencv could be found, sorry
         AC_MSG_RESULT(no)
-        AC_MSG_ERROR([cannot find opencv in ${with_opencv_tree}])
+        AC_MSG_ERROR([cannot find opencv in ${vlc_string_opencv_tree}])
       fi
     else
       PKG_CHECK_MODULES(OPENCV, opencv,
@@ -2035,21 +2015,17 @@ dnl
 VLC_FEATURE_OPTION([dvbpsi], [dvbpsi ts mux and demux module])
 have_dvbpsi=no
 AS_IF([VLC_FEATURE_ENABLED([dvbpsi])], [
-  AC_ARG_WITH(dvbpsi,
-  [  --with-dvbpsi=PATH      libdvbpsi headers and libraries])
-  AC_ARG_WITH(dvbpsi,
-  [  --with-dvbpsi-tree=PATH libdvbpsi tree for static linking])
-  case "${with_dvbpsi}" in
-  ""|yes)
-    if test -z "${with_dvbpsi_tree}"
-    then
+  VLC_STRING_OPTION([dvbpsi], [libdvbpsi headers and libraries], [PATH])
+  VLC_STRING_OPTION([dvbpsi-tree], [libdvbpsi tree for static linking], [PATH])
+  AS_IF([VLC_STRING_UNSET([dvbpsi])], [
+    AS_IF([VLC_STRING_UNSET([dvbpsi-tree])], [
       AC_CHECK_HEADERS(dvbpsi/dr.h,
         [ VLC_ADD_PLUGIN([ts])
           AS_IF([VLC_FEATURE_ENABLED([sout])], [
             VLC_ADD_PLUGIN([mux_ts])
           ])
           VLC_ADD_LIBS([mux_ts ts dvb],[-ldvbpsi])
-	  have_dvbpsi=yes],
+          have_dvbpsi=yes],
         [  AC_MSG_WARN([cannot find libdvbpsi headers]) ],
         [#if defined( HAVE_STDINT_H )
 #   include <stdint.h>
@@ -2060,14 +2036,14 @@ AS_IF([VLC_FEATURE_ENABLED([dvbpsi])], [
 #include <dvbpsi/descriptor.h>
 #include <dvbpsi/pat.h>
 #include <dvbpsi/pmt.h>])
-    else
-      AC_MSG_CHECKING(for libdvbpsi.a in ${with_dvbpsi_tree})
-      real_dvbpsi_tree="`cd ${with_dvbpsi_tree} 2>/dev/null && pwd`"
+    ], [
+      AC_MSG_CHECKING(for libdvbpsi.a in ${vlc_string_dvbpsi_tree})
+      real_dvbpsi_tree="`cd ${vlc_string_dvbpsi_tree} 2>/dev/null && pwd`"
       if test -z "${real_dvbpsi_tree}"
       then
         dnl  The given directory can't be found
         AC_MSG_RESULT(no)
-        AC_MSG_ERROR([cannot cd to ${with_dvbpsi_tree}])
+        AC_MSG_ERROR([cannot cd to ${vlc_string_dvbpsi_tree}])
       fi
       if test -f "${real_dvbpsi_tree}/src/.libs/libdvbpsi.a"
       then
@@ -2079,27 +2055,17 @@ AS_IF([VLC_FEATURE_ENABLED([dvbpsi])], [
         ])
         VLC_ADD_CPPFLAGS([mux_ts ts dvb],[-I${real_dvbpsi_tree}/src])
         VLC_ADD_LIBS([mux_ts ts dvb],[${real_dvbpsi_tree}/src/.libs/libdvbpsi.a])
-	have_dvbpsi=yes
+        have_dvbpsi=yes
       else
         dnl  The given libdvbpsi wasn't built
         AC_MSG_RESULT(no)
-        AC_MSG_ERROR([cannot find ${real_dvbpsi_tree}/src/.libs/libdvbpsi.a, make sure you compiled libdvbpsi in ${with_dvbpsi_tree}])
+        AC_MSG_ERROR([cannot find ${real_dvbpsi_tree}/src/.libs/libdvbpsi.a, make sure you compiled libdvbpsi in ${vlc_string_dvbpsi_tree}])
       fi
-    fi
-  ;;
-  no)
-    dnl  Compile without dvbpsi
-  ;;
-  *)
-    AC_MSG_CHECKING(for dvbpsi headers in ${with_dvbpsi})
-    if test -z "${with_dvbpsi}"
-    then
-      LDFLAGS_test=""
-      CPPFLAGS_test=""
-    else
-      LDFLAGS_test="-L${with_dvbpsi}/lib"
-      CPPFLAGS_test="-I${with_dvbpsi}/include"
-    fi
+    ])
+  ], [
+    AC_MSG_CHECKING(for dvbpsi headers in ${vlc_string_dvbpsi})
+    LDFLAGS_test="-L${vlc_string_dvbpsi}/lib"
+    CPPFLAGS_test="-I${vlc_string_dvbpsi}/include"
     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test}"
     AC_CHECK_HEADERS([dvbpsi/dr.h],[
       VLC_ADD_PLUGIN([ts])
@@ -2125,8 +2091,7 @@ AS_IF([VLC_FEATURE_ENABLED([dvbpsi])], [
 #include <dvbpsi/pat.h>
 #include <dvbpsi/pmt.h>])
     CPPFLAGS="${CPPFLAGS_save}"
-  ;;
-  esac
+  ])
   AC_CHECK_LIB(dvbpsi, dvbpsi_GenSDTSections, [
     AC_DEFINE(HAVE_DVBPSI_SDT, 1, [Define if you have dvbpsi_GenSDTSections.])
   ], [], [${LIBS_ts}])
@@ -2138,12 +2103,10 @@ dnl  Video4Linux plugin
 dnl
 VLC_FEATURE_OPTION([v4l], [Video4Linux input support], [disabled])
 AS_IF([VLC_FEATURE_ENABLED([v4l])], [
-  AC_ARG_WITH(v4l,
-    [  --with-v4l=PATH         path to a v4l-enabled kernel tree],[],[])
-  if test "${with_v4l}" != "no" -a -n "${with_v4l}"
-  then
-    VLC_ADD_CPPFLAGS([v4l],[-I${with_v4l}/include])
-  fi
+  VLC_STRING_OPTION([v4l], [path to a v4l-enabled kernel tree], [PATH])
+  AS_IF([VLC_STRING_SET([v4l])], [
+    VLC_ADD_CPPFLAGS([v4l],[-I${vlc_string_v4l}/include])
+  ])
 
   CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_v4l}"
   AC_CHECK_HEADERS(linux/videodev.h, [
@@ -2170,12 +2133,10 @@ dnl  Video4Linux2 plugin
 dnl
 VLC_FEATURE_OPTION([v4l2], [Video4Linux2 input support])
 AS_IF([VLC_FEATURE_ENABLED([v4l2])], [
-  AC_ARG_WITH(v4l2,
-    [  --with-v4l2=PATH        path to a v4l2-enabled kernel tree],[],[])
-  if test "${with_v4l2}" != "no" -a -n "${with_v4l2}"
-  then
-    VLC_ADD_CPPFLAGS([v4l2],[-I${with_v4l2}/include])
-  fi
+  VLC_STRING_OPTION([v4l2], [path to a v4l2-enabled kernel tree], [PATH])
+  AS_IF([VLC_STRING_SET([v4l2])], [
+    VLC_ADD_CPPFLAGS([v4l2],[-I${vlc_string_v4l2}/include])
+  ])
 
   CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_v4l2}"
   AC_CHECK_HEADERS(linux/videodev2.h, [
@@ -2203,12 +2164,12 @@ dnl
 VLC_FEATURE_OPTION([pvr], [PVR cards access module], [disabled])
 AS_IF([VLC_FEATURE_ENABLED([pvr])], [
   VLC_ADD_PLUGIN([pvr])
-  AC_ARG_WITH(videodev2,
-    [  --with-videodev2=FILE   Location of videodev2.h file (default /usr/include/linux/videodev2.h)],[],[])
-  if test "${with_videodev2}" != "no" -a -n "${with_videodev2}"
-  then
-    AC_DEFINE_UNQUOTED(VIDEODEV2_H_FILE, "${with_videodev2}", [Location of videodev2.h])
-  fi
+  VLC_STRING_OPTION([videodev2], [Location of videodev2.h file], [FILE], [
+    /usr/include/linux/videodev2.h
+  ])
+  AS_IF([VLC_STRING_SET([videodev2])], [
+    AC_DEFINE_UNQUOTED(VIDEODEV2_H_FILE, "${vlc_string_videodev2}", [Location of videodev2.h])
+  ])
 
   AC_CACHE_CHECK([for new linux/videodev2.h],
       [ac_cv_new_linux_videodev2_h],
@@ -2311,13 +2272,11 @@ dnl
 VLC_FEATURE_OPTION([dvb], [DVB-S/T/C card support])
 AS_IF([VLC_FEATURE_ENABLED([dvb])], [
     AS_IF([test "${have_dvbpsi}" = "yes" ],[
-    AC_ARG_WITH(dvb,
-     [  --with-dvb=PATH         path to a dvb- and v4l2-enabled kernel tree],[],[])
-     if test "${with_dvb}" != "no" -a -n "${with_dvb}"
-     then
-       VLC_ADD_CFLAGS([dvb],[-I${with_dvb}/include])
-     fi
-     CPPFLAGS="${CPPFLAGS_save} -I${with_dvb}/include"
+    VLC_STRING_OPTION([dvb], [path to a dvb- and v4l2-enabled kernel tree], [PATH])
+     AS_IF([VLC_STRING_SET([dvb])], [
+       VLC_ADD_CFLAGS([dvb],[-I${vlc_string_dvb}/include])
+     ])
+     CPPFLAGS="${CPPFLAGS_save} -I${vlc_string_dvb}/include"
      AC_CHECK_HEADERS(linux/dvb/version.h linux/dvb/frontend.h, [
      VLC_ADD_PLUGIN([dvb])
      ],[AC_MSG_WARN(linux-dvb headers not found, dvb disabled)])
@@ -2438,17 +2397,15 @@ dnl  modplug demux plugin
 dnl
 VLC_FEATURE_OPTION([mod], [Mod demux support])
 AS_IF([VLC_FEATURE_ENABLED([mod])], [
-  AC_ARG_WITH(mod-tree,
-  [  --with-mod-tree=PATH    mod tree for static linking])
-  if test -n "${with_mod_tree}"
-  then
-    AC_MSG_CHECKING(for libmodplug.a in ${with_mod_tree})
-    real_mod_tree="`cd ${with_mod_tree} 2>/dev/null && pwd`"
+  VLC_STRING_OPTION([mod-tree], [mod tree for static linking], [PATH])
+  AS_IF([VLC_STRING_SET([mod-tree])], [
+    AC_MSG_CHECKING(for libmodplug.a in ${vlc_string_mod_tree})
+    real_mod_tree="`cd ${vlc_string_mod_tree} 2>/dev/null && pwd`"
     if test -z "${real_mod_tree}"
     then
       dnl  The given directory can't be found
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot cd to ${with_mod_tree}])
+      AC_MSG_ERROR([cannot cd to ${vlc_string_mod_tree}])
     fi
     if test -f "${real_mod_tree}/src/.libs/libmodplug.a"
     then
@@ -2460,15 +2417,15 @@ AS_IF([VLC_FEATURE_ENABLED([mod])], [
     else
       dnl  The given mod wasn't built
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot find ${real_mod_tree}/src/.libs/libmodplug.a, make sure you compiled mod in ${with_mod_tree}])
+      AC_MSG_ERROR([cannot find ${real_mod_tree}/src/.libs/libmodplug.a, make sure you compiled mod in ${vlc_string_mod_tree}])
     fi
-  else
+  ], [
     PKG_CHECK_MODULES(LIBMODPLUG, libmodplug >= 0.8,
         [ VLC_ADD_PLUGIN([mod])
           VLC_ADD_CXXFLAGS([mod],[$LIBMODPLUG_CFLAGS])
           VLC_ADD_LIBS([mod],[$LIBMODPLUG_LIBS])
         ],[AC_MSG_WARN([libmodplug not found!])])
-  fi
+  ])
 ])
 
 dnl
@@ -2490,17 +2447,15 @@ dnl
 VLC_FEATURE_OPTION([gme], [Game Music Emu demux support])
 AS_IF([VLC_FEATURE_ENABLED([gme]) && test "${CXX}" != ""], [
   AC_LANG_PUSH(C++)
-  AC_ARG_WITH(gme-tree,
-  [  --with-gme-tree=PATH    gme tree for static linking])
-  if test -n "${with_gme_tree}"
-  then
-    AC_MSG_CHECKING(for libgme.a in ${with_mod_tree})
-    real_gme_tree="`cd ${with_gme_tree} 2>/dev/null && pwd`"
+  VLC_STRING_OPTION([gme-tree], [gme tree for static linking], [PATH])
+  AS_IF([VLC_STRING_SET([gme-tree])], [
+    AC_MSG_CHECKING(for libgme.a in ${vlc_string_mod_tree})
+    real_gme_tree="`cd ${vlc_string_gme_tree} 2>/dev/null && pwd`"
     if test -z "${real_gme_tree}"
     then
       dnl  The given directory can't be found
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot cd to ${with_gme_tree}])
+      AC_MSG_ERROR([cannot cd to ${vlc_string_gme_tree}])
     fi
     if test -f "${real_gme_tree}/gme/libgme.a"
     then
@@ -2512,11 +2467,11 @@ AS_IF([VLC_FEATURE_ENABLED([gme]) && test "${CXX}" != ""], [
     else
       dnl  The given gme wasn't built
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot find ${real_mod_tree}/gme/libgme.a, make sure you compiled gme in ${with_gme_tree}])
+      AC_MSG_ERROR([cannot find ${real_mod_tree}/gme/libgme.a, make sure you compiled gme in ${vlc_string_gme_tree}])
     fi
-  else
+  ], [
       AC_MSG_WARN([only static linking is available, you must provide a gme-tree])
-  fi
+  ])
   AC_LANG_POP(C++)
 ])
 
@@ -2547,24 +2502,20 @@ dnl  mad plugin
 dnl
 VLC_FEATURE_OPTION([mad], [libmad module])
 AS_IF([VLC_FEATURE_ENABLED([mad])], [
-  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
+  VLC_STRING_OPTION([mad], [path to libmad], [PATH])
+  AS_IF([VLC_STRING_SET([mad])], [
+    VLC_ADD_CPPFLAGS([mpgatofixed32],[-I${vlc_string_mad}/include])
+    VLC_ADD_LIBS([mpgatofixed32],[-L${vlc_string_mad}/lib])
+  ])
 
-  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`"
+  VLC_STRING_OPTION([mad-tree], [mad tree for static linking], [PATH])
+  AS_IF([VLC_STRING_SET([mad-tree])], [
+    real_mad_tree="`cd ${vlc_string_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 doesn't exist])
+      AC_MSG_ERROR([${vlc_string_mad_tree} directory doesn't exist])
     fi
     dnl  Use a custom libmad
     AC_MSG_CHECKING(for mad.h in ${real_mad_tree})
@@ -2584,7 +2535,7 @@ AS_IF([VLC_FEATURE_ENABLED([mad])], [
       AC_MSG_RESULT(no)
       AC_MSG_ERROR([the specified tree doesn't have mad.h])
     fi
-  else
+  ], [
     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_mpgatofixed32}"
     LDFLAGS="${LDFLAGS_save} ${LIBS_mpgatofixed32}"
     AC_CHECK_HEADERS(mad.h, ,
@@ -2595,7 +2546,7 @@ AS_IF([VLC_FEATURE_ENABLED([mad])], [
       [ AC_MSG_ERROR([Cannot find libmad library...]) ])
     CPPFLAGS="${CPPFLAGS_save}"
     LDFLAGS="${LDFLAGS_save}"
-  fi
+  ])
 ])
 
 dnl
@@ -2787,17 +2738,15 @@ dnl  faad decoder plugin
 dnl
 VLC_FEATURE_OPTION([faad], [faad codec], [disabled])
 AS_IF([VLC_FEATURE_ENABLED([faad])], [
-  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`"
+  VLC_STRING_OPTION([faad-tree], [faad tree for static linking], [PATH])
+  AS_IF([VLC_STRING_SET([faad-tree])], [
+    AC_MSG_CHECKING(for libfaad.a in ${vlc_string_faad_tree})
+    real_faad_tree="`cd ${vlc_string_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}])
+      AC_MSG_ERROR([cannot cd to ${vlc_string_faad_tree}])
     fi
     if test -f "${real_faad_tree}/libfaad/.libs/libfaad.a"
     then
@@ -2809,9 +2758,9 @@ AS_IF([VLC_FEATURE_ENABLED([faad])], [
     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}])
+      AC_MSG_ERROR([cannot find ${real_faad_tree}/libfaad/.libs/libfaad.a, make sure you compiled libfaad in ${vlc_string_faad_tree}])
     fi
-  else
+  ], [
     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_faad}"
     LDFLAGS="${LDFLAGS_save} ${LIBS_faad}"
     AC_CHECK_HEADERS(faad.h, ,
@@ -2825,7 +2774,7 @@ AS_IF([VLC_FEATURE_ENABLED([faad])], [
         [ AC_MSG_ERROR([Cannot find libfaad library...]) ]))
     LDFLAGS="${LDFLAGS_save}"
     CPPFLAGS="${CPPFLAGS_save}"
-  fi
+  ])
 ])
 
 dnl
@@ -2886,18 +2835,15 @@ dnl A52/AC3 decoder plugin
 dnl
 VLC_FEATURE_OPTION([a52], [A/52 support with liba52])
 AS_IF([VLC_FEATURE_ENABLED([a52])], [
-  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`"
+  VLC_STRING_OPTION([a52], [a52 headers and libraries], [PATH])
+  VLC_STRING_OPTION([a52-tree], [a52 tree for static linking], [PATH])
+  AS_IF([VLC_STRING_SET([a52-tree])], [
+    real_a52_tree="`cd ${vlc_string_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 doesn't exist])
+      AC_MSG_ERROR([${vlc_string_a52_tree} directory doesn't exist])
     fi
     dnl  Use a custom a52dec
     AC_MSG_CHECKING(for a52.h in ${real_a52_tree}/include)
@@ -2924,15 +2870,11 @@ AS_IF([VLC_FEATURE_ENABLED([a52])], [
       AC_MSG_RESULT(no)
       AC_MSG_ERROR([the specified tree doesn't have a52.h])
     fi
-  else
-    if test -z "${with_a52}"
-    then
-      LDFLAGS_test=""
-      CPPFLAGS_test=""
-    else
-      LDFLAGS_test="-L${with_a52}/lib"
-      CPPFLAGS_test="-I${with_a52}/include"
-    fi
+  ], [
+    AS_IF([VLC_STRING_SET([a52])], [
+      LDFLAGS_test="-L${vlc_string_a52}/lib"
+      CPPFLAGS_test="-I${vlc_string_a52}/include"
+    ])
     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test} ${CPPFLAGS_a52tofloat32}"
     LDFLAGS="${LDFLAGS_save} ${LDFLAGS_test} ${LIBS_a52tofloat32}"
     AC_CHECK_HEADERS(a52dec/a52.h, [
@@ -2948,12 +2890,11 @@ AS_IF([VLC_FEATURE_ENABLED([a52])], [
     ])
     CPPFLAGS="${CPPFLAGS_save}"
     LDFLAGS="${LDFLAGS_save}"
-  fi
+  ])
 ])
 
-AC_ARG_WITH(a52-fixed,
-      [  --with-a52-fixed        specify if liba52 has been compiled with fixed point support],
-      [
+VLC_FEATURE_OPTION([a52-fixed], [specify if liba52 has been compiled with fixed point support], [disabled])
+AS_IF([VLC_FEATURE_ENABLED([a52-fixed])], [
         VLC_ADD_CPPFLAGS([a52tofloat32],[-DLIBA52_FIXED]) ])
 
 dnl
@@ -3028,16 +2969,14 @@ dnl H264 encoder plugin (using libx264)
 dnl
 VLC_FEATURE_OPTION([x264], [H264 encoding support with libx264])
 AS_IF([VLC_FEATURE_ENABLED([x264])], [
-  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`"
+  VLC_STRING_OPTION([x264-tree], [x264 tree for static linking], [PATH])
+  AS_IF([VLC_STRING_SET([x264-tree])], [
+    real_x264_tree="`cd ${vlc_string_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 doesn't exist])
+      AC_MSG_ERROR([${vlc_string_x264_tree} directory doesn't exist])
     fi
     dnl  Use a custom libx264
     AC_MSG_CHECKING(for x264.h in ${real_x264_tree})
@@ -3061,7 +3000,7 @@ AS_IF([VLC_FEATURE_ENABLED([x264])], [
       AC_MSG_RESULT(no)
       AC_MSG_ERROR([the specified tree doesn't have x264.h])
     fi
-  else
+  ], [
       PKG_CHECK_MODULES(X264,x264 >= 0.76, [
         VLC_ADD_PLUGIN([x264])
         VLC_ADD_LDFLAGS([x264],[${X264_LIBS}])
@@ -3086,7 +3025,7 @@ AS_IF([VLC_FEATURE_ENABLED([x264])], [
           ])
       ])
     LDFLAGS="${LDFLAGS_save}"
-  fi
+  ])
 ])
 
 dnl
@@ -3326,12 +3265,10 @@ VLC_FEATURE_OPTION([sdl], [SDL support])
 VLC_FEATURE_OPTION([sdl-image], [SDL image support])
 AS_IF([VLC_FEATURE_ENABLED([sdl])], [
   SDL_PATH="${PATH}"
-  AC_ARG_WITH(sdl-config-path,
-    [  --with-sdl-config-path=PATH sdl-config path (default search in \$PATH)],
-    [ if test "${with_sdl_config_path}" != "no"
-      then
-        SDL_PATH="${with_sdl_config_path}:${PATH}"
-      fi ])
+  VLC_STRING_OPTION([sdl-config-path], [sdl-config path], [PATH], [search in \$PATH])
+    AS_IF([VLC_STRING_SET([sdl-config-path])], [
+      SDL_PATH="${vlc_string_sdl_config_path}:${PATH}"
+    ])
   AC_PATH_PROG(SDL_CONFIG, sdl-config, no, ${SDL_PATH})
   SDL_HEADER="SDL/SDL.h"
   SDL_IMAGE="SDL/SDL_image.h"
@@ -3552,20 +3489,19 @@ dnl  try to find using: 1 - given location; 2 - directfb-config; 3 - pkg-config
 dnl  TODO: support for static linking
 dnl
 VLC_FEATURE_OPTION([directfb], [DirectFB support], [disabled])
-AC_ARG_WITH(directfb,
-  [  --with-directfb=PATH    path to DirectFB headers and libraries])
+VLC_STRING_OPTION([directfb], [path to DirectFB headers and libraries], [PATH])
 AS_IF([VLC_FEATURE_ENABLED([directfb])], [
     have_directfb="false"
     CPPFLAGS_mydirectfb=
     LIBS_mydirectfb=
-    if test "${with_directfb}" != "no" -a -n "${with_directfb}"; then
+    AS_IF([VLC_STRING_SET([directfb])], [
         dnl Trying the given location
         CPPFLAGS_save="${CPPFLAGS}"
         LIBS_save="${LIBS}"
 
-        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/"
+        CPPFLAGS_new="-I${vlc_string_directfb}/include -D_REENTRANT -D_GNU_SOURCE"
+        LIBS_new="-L${vlc_string_directfb}/lib/fusion/.libs/ -L${vlc_string_directfb}/lib/direct/.libs/"
+        LIBS_new="${LIBS_new} -L${vlc_string_directfb}/src/.libs/"
 
         CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_new}"
         LIBS="${LIBS} ${LIBS_new}"
@@ -3587,7 +3523,7 @@ AS_IF([VLC_FEATURE_ENABLED([directfb])], [
             LIBS_mydirectfb="${LIBS_new} -lz -ldl -ldirectfb -lfusion -ldirect -lpthread"
             CPPFLAGS_mydirectfb="${CPPFLAGS_new}"
         fi
-    else
+    ], [
         dnl Look for directfb-config
         AC_PATH_PROG(DIRECTFB_CONFIG, directfb-config, no, ${PATH})
         if test "${DIRECTFB_CONFIG}" != "no"; then
@@ -3602,7 +3538,7 @@ AS_IF([VLC_FEATURE_ENABLED([directfb])], [
                 have_directfb="true"
                 ], [have_directfb="false"])
         fi
-    fi
+    ])
     if test "${have_directfb}" = "true"; then
         VLC_ADD_PLUGIN([directfb])
         VLC_ADD_CPPFLAGS([directfb],[${CPPFLAGS_mydirectfb}])
@@ -3622,13 +3558,11 @@ AS_IF([VLC_FEATURE_ENABLED([ggi])], [
   AC_CHECK_HEADER([ggi/ggi.h],[
     VLC_ADD_PLUGIN([ggi])
     VLC_ADD_LIBS([ggi],[-lggi])
-    AC_ARG_WITH(ggi,
-      [  --with-ggi=PATH         path to libggi],
-      [ if test "${with_ggi}" != "no" -a -n "${with_ggi}"
-        then
-          VLC_ADD_CPPFLAGS([ggi],[-I${with_ggi}/include])
-          VLC_ADD_LIBS([ggi],[-L${with_ggi}/lib])
-        fi ])
+    VLC_STRING_OPTION([ggi], [path to libggi], [PATH])
+    AS_IF([VLC_STRING_SET([ggi])], [
+      VLC_ADD_CPPFLAGS([ggi],[-I${vlc_string_ggi}/include])
+      VLC_ADD_LIBS([ggi],[-L${vlc_string_ggi}/lib])
+    ])
     ],[
        AC_MSG_ERROR([LibGGI development files can't be found])
     ])
@@ -3747,19 +3681,23 @@ dnl  CyberLink for C++ UPnP stack
 dnl
 VLC_FEATURE_OPTION([cyberlin], [CyberLink for C++ UPnP stack], [disabled])
   AS_IF([VLC_FEATURE_ENABLED([cyberlink])], [
-  AC_ARG_WITH(cyberlink-tree,
-    [  --with-cyberlink-tree=PATH CyberLink for C++ tree for static linking])
+  VLC_STRING_OPTION([cyberlink-tree], [CyberLink for C++ tree for static linking], [PATH])
 
   dnl
   dnl test for --with-cyberlink-tree
   dnl
-  AS_IF([test ! -z "${with_cyberlink_tree}" -a "${CXX}" != ""], [
+  AS_IF([{ VLC_STRING_SET([cyberlink-tree]) || test "x${have_contrib_libs}" = "xyes" ;} && test "${CXX}" != ""], [
     AC_LANG_PUSH(C++)
-    real_cyberlink_tree="`cd ${with_cyberlink_tree} 2>/dev/null && pwd`"
+    AS_IF([VLC_STRING_UNSET([cyberlink-tree])], [
+      try_cyberlink_tree="${CONTRIB_DIR}/src/clinkcc"
+    ], [
+      try_cyberlink_tree="${vlc_string_cyberlink_tree}"
+    ])
+    real_cyberlink_tree="`cd ${try_cyberlink_tree} 2>/dev/null && pwd`"
     AS_IF([test -z "${real_cyberlink_tree}"], [
       dnl  The given directory can't be found
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot cd to ${with_cyberlink_tree}])
+      AC_MSG_ERROR([cannot cd to ${try_cyberlink_tree}])
     ])
     CPPFLAGS_save="${CPPFLAGS}"
     CPPFLAGS_cyberlink="-I${real_cyberlink_tree}/include"
@@ -3770,7 +3708,7 @@ VLC_FEATURE_OPTION([cyberlin], [CyberLink for C++ UPnP stack], [disabled])
       ],[
         AC_MSG_ERROR([cannot find CyberLink for C++ headers])
       ])
-    AC_MSG_CHECKING(for libclink.a in ${with_cyberlink_tree})
+    AC_MSG_CHECKING(for libclink.a in ${try_cyberlink_tree})
     AS_IF([test -f "${real_cyberlink_tree}/lib/unix/libclink.a"], [
       AC_MSG_RESULT(${real_cyberlink_tree}/lib/unix/libclink.a)
       dnl The mere fact that we have to make such an ugly check sucks
@@ -3806,7 +3744,7 @@ class testclass : public SearchResponseListener, public MediaPlayer
       VLC_ADD_LIBS([upnp_cc], [${real_cyberlink_tree}/lib/unix/libclink.a -lpthread ${LIBS_cclink}])
     ], [
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot find ${real_cyberlink_tree}/lib/unix/libclink.a, make sure you compiled CyberLink for C++ in ${with_cyberlink_tree}])
+      AC_MSG_ERROR([cannot find ${real_cyberlink_tree}/lib/unix/libclink.a, make sure you compiled CyberLink for C++ in ${try_cyberlink_tree}])
     ])
     CPPFLAGS="${CPPFLAGS_save}"
     AC_LANG_POP([C++])
@@ -4239,30 +4177,29 @@ dnl
 dnl SQLite
 dnl
 VLC_FEATURE_OPTION([sqlite], [sqlite support])
-AC_ARG_WITH(sqlite,
-  [  --with-sqlite=PATH      sqlite path linking])
+VLC_STRING_OPTION([sqlite], [sqlite path linking], [PATH])
 if test "${SYS}" != "darwin"; then
   PKG_ENABLE_MODULES_VLC([SQLITE], [], [sqlite3 >= 3.6.0], [sqlite3], [auto])
 else
   AS_IF([VLC_FEATURE_ENABLED([sqlite])], [
     AC_CHECK_HEADERS(sqlite3.h, [
         VLC_ADD_PLUGIN([sqlite])
-        if test "${with_sqlite}" != "no" -a -n "${with_sqlite}"; then
-          AC_MSG_CHECKING(existence of sqlite directory in ${with_sqlite})
-          real_sqlite="`cd ${with_sqlite} 2>/dev/null && pwd`"
+        AS_IF([VLC_STRING_SET([sqlite])], [
+          AC_MSG_CHECKING(existence of sqlite directory in ${vlc_string_sqlite})
+          real_sqlite="`cd ${vlc_string_sqlite} 2>/dev/null && pwd`"
           if test -z "${real_sqlite}"
           then
             dnl  The given directory can't be found
             AC_MSG_RESULT(no)
-            AC_MSG_ERROR([cannot cd to ${with_sqlite}])
+            AC_MSG_ERROR([cannot cd to ${vlc_string_sqlite}])
           fi
-          VLC_ADD_CFLAGS([sqlite],[-I${with_sqlite}/include])
-          VLC_ADD_LIBS([sqlite], [-L${with_sqlite}/lib -lsqlite3])
+          VLC_ADD_CFLAGS([sqlite],[-I${vlc_string_sqlite}/include])
+          VLC_ADD_LIBS([sqlite], [-L${vlc_string_sqlite}/lib -lsqlite3])
           AC_MSG_RESULT(yes)
           have_sqlite="yes"
-        else
+        ], [
           VLC_ADD_LIBS([sqlite], [-lsqlite3])
-        fi
+        ])
         AC_DEFINE([SQLITE_MODULE], 1, [Define if you want to use SQLite module]) ],
         AC_MSG_ERROR([sqlite3 is required for sqlite module]) )
   ])
@@ -4313,17 +4250,15 @@ AS_IF([test "${SYS}" = "mingw32"], [
   VLC_FEATURE_DEFAULT_DISABLE([activex])
 ])
 VLC_FEATURE_OPTION([activex], [build a vlc-based ActiveX control], [enabled on Win32])
-AC_ARG_WITH(wine-sdk-path,
-  [  --with-wine-sdk-path=PATH path to wine sdk])
+VLC_STRING_OPTION([wine-sdk-path], [path to wine sdk], [PATH])
 AS_IF([VLC_FEATURE_ENABLED([activex]) && test "${SYS}" = "mingw32"], [
     AC_CHECK_PROGS(MIDL, [midl], no)
-    if test "${with_wine_sdk_path}" != ""
-    then
-       WINE_SDK_PATH=${with_wine_sdk_path}
+    AS_IF([VLC_STRING_SET([wine-sdk-path])], [
+       WINE_SDK_PATH=${vlc_string_wine_sdk_path}
        AC_PATH_PROG(WIDL, widl, no, [$WINE_SDK_PATH/bin:$WINE_SDK_PATH/tools/widl])
-    else
+    ], [
        WIDL=no
-    fi
+    ])
     AC_LANG_PUSH(C++)
     AC_CHECK_HEADERS(ole2.h,
       [AC_CHECK_HEADERS(olectl.h,
@@ -4358,13 +4293,11 @@ dnl  Mozilla plugin
 dnl
 mozilla=false
 VLC_FEATURE_OPTION([mozilla], [build a vlc-based Firefox/Mozilla plugin], [disabled])
-AC_ARG_WITH(mozilla-sdk-path,
-  [  --with-mozilla-sdk-path=PATH path to mozilla sdk])
-AC_ARG_WITH(mozilla-pkg,
-  [  --with-mozilla-pkg=PKG  look for PKG.pc to build the mozilla plugin.])
+VLC_STRING_OPTION([mozilla-sdk-path], [path to mozilla sdk], [PATH])
+VLC_STRING_OPTION([mozilla-pkg], [look for PKG.pc to build the mozilla plugin.], [PKG])
 AC_LANG_PUSH(C++)
 AS_IF([VLC_FEATURE_ENABLED([mozilla])], [
-  AS_IF([test "${with_mozilla_sdk_path}" = "" -o "${with_mozilla_sdk_path}" = "no"],
+  AS_IF([VLC_STRING_UNSET([mozilla-sdk-path])],
     [
     dnl pkg-config
     dnl As we want to do a loop due to the number of name possible for the .pc
@@ -4379,7 +4312,7 @@ AS_IF([VLC_FEATURE_ENABLED([mozilla])], [
       found=1
     else
       if test -n "$PKG_CONFIG"; then
-	for i in "${with_mozilla_pkg}" libxul {seamonkey,iceape,xulrunner,firefox,iceweasel,mozilla}-plugin; do
+	for i in "${vlc_string_mozilla_pkg}" libxul {seamonkey,iceape,xulrunner,firefox,iceweasel,mozilla}-plugin; do
 	  echo "Trying to find $i.pc files" >&5
 	  if $PKG_CONFIG --exists --print-errors "$i" 2>&5
 	  then
@@ -4470,18 +4403,22 @@ AS_IF([VLC_FEATURE_ENABLED([mozilla])], [
       MOZILLA_SDK_PATH="`${MOZILLA_CONFIG} --prefix`"
     ])
     dnl End of moz_sdk = ""
-  ],[
+  ])
+
+  AS_IF([{ VLC_STRING_SET([mozilla-sdk-path]) || test "x${have_contrib_libs}" = "xyes" ;}], [
+    AS_IF([VLC_STRING_UNSET([mozilla-sdk-path])], [
+      try_sdk_path="${CONTRIB_DIR}/gecko-sdk"
+    ], [
+      try_sdk_path="${vlc_string_mozilla_sdk_path}"
+    ])
+
     dnl special case for mingw32
     if test "${SYS}" = "mingw32"
     then
       AC_CHECK_TOOL(CYGPATH, cygpath, "")
-      dnl latest gecko sdk does not have an xpcom directory
-      if test -d "${with_mozilla_sdk_path}/xpcom"; then
-          mozilla_sdk_xpcom="/xpcom"
-      fi
     fi
 
-    real_mozilla_sdk="`cd ${with_mozilla_sdk_path} 2>/dev/null && pwd`"
+    real_mozilla_sdk="`cd ${try_mozilla_sdk_path} 2>/dev/null && pwd`"
     CPPFLAGS="${CPPFLAGS_save} -I${real_mozilla_sdk} -I${real_mozilla_sdk}/include"
     MOZILLA_REQUIRED_HEADERS=1
     AC_CHECK_HEADERS(mozilla-config.h,,MOZILLA_REQUIRED_HEADERS=0)
diff --git a/m4/vlc_features.m4 b/m4/vlc_features.m4
index ee31713..ae11445 100644
--- a/m4/vlc_features.m4
+++ b/m4/vlc_features.m4
@@ -77,10 +77,23 @@ AC_DEFUN([VLC_FEATURE_DEFAULT_DISABLE], [
   _VLC_FEATURE_DEFAULT([$1], [no])
 ])
 
+dnl VLC_STRING_FORCE(WITH-STRING, VALUE, [REASON])
+dnl Force string option WITH-STRING to be set to VALUE.
+AC_DEFUN([VLC_STRING_FORCE], [
+  [vlc_string_force_]_VLC_FEATURE_STRING([$1])[="]$2["]
+  AS_ECHO(["Assuming --with-$1=$2]m4_quote(m4_ifnblank([$2], [ $2]))["])
+])
+
+dnl VLC_STRING_DEFAULT(WITH-STRING, VALUE)
+dnl Set string option to VALUE by default.
+AC_DEFUN([VLC_STRING_DEFAULT], [
+  [vlc_string_default_]_VLC_FEATURE_STRING([$1])[="]$2["]
+])
+
 
 
 dnl ==========================================================================
-dnl Macros for probing the state of features.
+dnl Macros for probing the state of features and string options.
 dnl ==========================================================================
 
 dnl VLC_FEATURE_(NOT_)FORCE_ENABLED/DISABLED(ENABLE-STRING)
@@ -112,10 +125,36 @@ AC_DEFUN([VLC_FEATURE_DEFAULT_ENABLED],
 AC_DEFUN([VLC_FEATURE_DEFAULT_DISABLED],
   [_VLC_FEATURE_CHECK_VARIABLE([$1], [vlc_feature_default], [= "xno" ])])
 
+dnl VLC_STRING_(NOT_)FORCED(WITH-STRING)
+dnl Check if a string is (or isn't) forced to be set.
+AC_DEFUN([VLC_STRING_FORCED],
+  [_VLC_FEATURE_CHECK_VARIABLE([$1], [vlc_string_force], [!= "x" ])])
+AC_DEFUN([VLC_STRING_NOT_FORCED],
+  [_VLC_FEATURE_CHECK_VARIABLE([$1], [vlc_string_force], [= "x" ])])
+
+dnl VLC_STRING_(NOT_)USER_SET(WITH-STRING)
+dnl Check if a string is (or isn't) passed via ./configure.
+AC_DEFUN([VLC_STRING_USER_SET],
+  [_VLC_FEATURE_CHECK_VARIABLE([$1], [with], [!= "x" ])])
+AC_DEFUN([VLC_STRING_NOT_USER_SET],
+  [_VLC_FEATURE_CHECK_VARIABLE([$1], [with], [= "x" ])])
+
+dnl VLC_STRING_(NOT_)DEFAULT_SET(WITH-STRING)
+dnl Check if a string is (or isn't) default set by configure.ac authors.
+AC_DEFUN([VLC_STRING_DEFAULT_SET],
+  [_VLC_FEATURE_CHECK_VARIABLE([$1], [vlc_string_default], [!= "x" ])])
+AC_DEFUN([VLC_STRING_NOT_DEFAULT_SET],
+  [_VLC_FEATURE_CHECK_VARIABLE([$1], [vlc_string_default], [= "x" ])])
+
+dnl VLC_STRING(WITH-STRING)
+dnl Obtain the string value for a string option.
+AC_DEFUN([VLC_STRING], [
+])
+
 
 
 dnl ==========================================================================
-dnl Convenient macros for probing the state of features.
+dnl Convenient macros for probing the state of features and string options.
 dnl ==========================================================================
 
 dnl VLC_FEATURE_(NOT_)REQUESTED/REMOVED(ENABLE-STRING)
@@ -145,6 +184,22 @@ AC_DEFUN([VLC_FEATURE_ENABLED],
 AC_DEFUN([VLC_FEATURE_DISABLED],
   [_VLC_FEATURE_CHECK_VARIABLE([$1], [vlc_feature], [= "xno"])])
 
+dnl VLC_STRING_REQUESTED(WITH-STRING)
+dnl VLC_STRING_NOT_REQUESTED(WITH-STRING)
+dnl Check if a string option is (or isn't) forced or user set.
+AC_DEFUN([VLC_STRING_REQUESTED],
+  [{ ][VLC_STRING_FORCED([$1])][ || ][VLC_STRING_USER_SET([$1])][; }])
+AC_DEFUN([VLC_STRING_NOT_REQUESTED],
+  [AS_IF([VLC_STRING_REQUESTED([$1])], [false], [true])])
+
+dnl VLC_STRING_SET(WITH-STRING)
+dnl VLC_STRING_UNSET(WITH-STRING)
+dnl Check if a string option is (or isn't) explicitly or default set.
+AC_DEFUN([VLC_STRING_SET],
+  [{ ][VLC_STRING_REQUESTED([$1])][ || ][VLC_STRING_DEFAULT_SET([$1])][; }])
+AC_DEFUN([VLC_STRING_UNSET],
+  [AS_IF([VLC_STRING_SET([$1])], [false], [true])])
+
 
 
 dnl ==========================================================================
@@ -207,3 +262,39 @@ AC_DEFUN([VLC_FEATURE_OPTION], [
   m4_popdef([var])
   m4_popdef([with_without])
 ])
+
+dnl VLC_STRING_OPTION(WITH-STRING, DESCRIPTION, VARIABLE,
+dnl                   [DEFAULT-STRING])
+dnl
+dnl Wrap around AC_ARG_WITH to provide string parameters for VLC.
+dnl DESCRIPTION should contain an informative string describing what
+dnl the VARIABLE is used for (you should use VARIABLE inside it).
+dnl VARIABLE is the right hand side of the assignment, so:
+dnl --with-foo=VARIABLE.
+dnl DEFAULT-STRING is optional and will be used in AS_HELP_STRING.
+dnl The resulting string is stored in vlc_string_WITH_STRING.
+AC_DEFUN([VLC_STRING_OPTION], [
+  m4_pushdef([default_string],
+             [m4_ifnblank([$4], [ @<:@default: ]m4_quote([$4])[@:>@])])
+  m4_pushdef([var], [vlc_string_]_VLC_FEATURE_STRING([$1]))
+
+  m4_ifblank([$2], [m4_fatal([Don't leave description blank for $1])])
+  m4_ifblank([$3], [m4_fatal([Don't leave variable blank for $1])])
+
+  AC_ARG_WITH([$1], [AS_HELP_STRING([--with-$1=]$3, m4_quote([$2]default_string))])
+
+  AS_IF([test "x][VLC_STRING([$1])][" = "xno"], [
+    AC_MSG_WARN(["no" is an uncommon string for --with-$1])
+  ])
+
+  AS_IF([VLC_STRING_FORCED([$1])], var[="${vlc_string_force_]_VLC_FEATURE_STRING([$1])[}"],
+    AS_IF([VLC_STRING_USER_SET([$1])], var[="${with_]_VLC_FEATURE_STRING([$1])[}"],
+      AS_IF([VLC_STRING_DEFAULT_SET([$1])],
+        var[="${vlc_string_default_]_VLC_FEATURE_STRING([$1])[}"]
+      )
+    )
+  )
+
+  m4_popdef([var])
+  m4_popdef([default_string])
+])
-- 
1.6.6.1


From 9b3409b9dc25b7ccac17cc3fc1736905382d1ebc Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Sat, 30 Jan 2010 18:43:35 +0100
Subject: [PATCH 03/10] Put system handling into separate file.

Also reoorder system specific stuff a bit.

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac     |  149 +++++++++++++++++++++---------------------------------
 m4/vlc_system.m4 |   29 +++++++++++
 2 files changed, 87 insertions(+), 91 deletions(-)
 create mode 100644 m4/vlc_system.m4

diff --git a/configure.ac b/configure.ac
index 94753d0..909122d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,39 +155,34 @@ LDFLAGS_vlc="${LDFLAGS}"
 
 dnl
 dnl  Check the operating system
+dnl  Disable features that we're going to default enable based
+dnl  on the operating system.
 dnl
-case "${host_os}" in
-  "")
-    SYS=unknown
-    ;;
-  linux*)
-    SYS=linux
-    ;;
-  bsdi*)
-    SYS=bsdi
+VLC_CHECK_SYS()
+VLC_FEATURE_DEFAULT_DISABLE([peflags])
+AS_CASE(["${SYS}"], 
+  [bsdi], [
     CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
     VLC_ADD_LIBS([dvd dvdcss vcd cdda vcdx],[-ldvd])
-    ;;
-  *bsd*)
-    SYS="${host_os}"
+  ],
+  [bsd], [
     CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
-    case "${host_os}" in
-      freebsd*)
+    AS_CASE(["${host_os}"],
+      [freebsd*], [
         CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include"
         CPPFLAGS="${CPPFLAGS_save}"
         LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib"
         LDFLAGS="${LDFLAGS_save}"
-        ;;
-      openbsd*)
+      ],
+      [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
-    ;;
-  darwin*)
-    SYS=darwin
+      ]
+    )
+  ],
+  [darwin], [
     CFLAGS_save="${CFLAGS_save} -D_INTL_REDIRECT_MACROS"; CFLAGS="${CFLAGS_save}"
     CXXFLAGS_save="${CXXFLAGS_save} -D_INTL_REDIRECT_MACROS"; CXXFLAGS="${CXXFLAGS_save}"
     OBJCFLAGS_save="${OBJCFLAGS_save} -D_INTL_REDIRECT_MACROS -std=gnu99"; OBJCFLAGS="${OBJCFLAGS_save}"
@@ -246,8 +241,8 @@ case "${host_os}" in
         MACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}
         export MACOSX_DEPLOYMENT_TARGET
     ])
-    ;;
-  darwin9*)
+  ],
+  [darwin9*], [
     if test "${host_cpu}" = "i386"; then
         dnl Due to a ld(64) bug in 10.5 we cannot use our mmx code
         dnl without hacking it a lot, we disable mmx and sse.
@@ -266,69 +261,28 @@ case "${host_os}" in
             VLC_FEATURE_FORCE_DISABLE([sse], [due to a bug in ld])
         fi
     fi
-    ;;
-  *mingw32* | *cygwin* | *wince* | *mingwce*)
-    AC_CHECK_TOOL(WINDRES, windres, :)
-    AC_CHECK_TOOL(OBJCOPY, objcopy, :)
-
-    case "${host_os}" in
-      *wince* | *mingwce* | *mingw32ce*)
-        SYS=mingwce
-        dnl Sadly CeGCC still needs non-wince macros
-        AC_DEFINE([_WIN32_WINNT], 0x0501, [Define to '0x0500' for Windows 2000 APIs.])
-        ;;
-      *mingw32*)
-        SYS=mingw32
-        AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
-        ;;
-      *cygwin*)
-        dnl Check if we are using the mno-cygwin mode in which case we are
-        dnl actually dealing with a mingw32 compiler.
-        AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
-        AC_EGREP_CPP(yes,
-            [#ifdef WIN32
-             yes
-             #endif],
-            SYS=mingw32, AC_MSG_ERROR([VLC requires -mno-cygwin]))
-        ;;
-    esac
+  ],
+  [mingwce], [
+    dnl Sadly CeGCC still needs non-wince macros
+    AC_DEFINE([_WIN32_WINNT], 0x0501, [Define to '0x0500' for Windows 2000 APIs.])
 
-    if test "${SYS}" = "mingw32"; then
-        # add ws2_32 for closesocket, select, recv
-        VLC_ADD_LIBS([libvlccore],[-lws2_32 -lnetapi32 -lwinmm])
-        VLC_ADD_LDFLAGS([vlc],[-mwindows])
-        VLC_ADD_LIBS([activex mozilla],[-lgdi32])
-        VLC_ADD_LIBS([cdda vcdx sdl_image aout_sdl vout_sdl],[-lwinmm])
-        VLC_ADD_LIBS([access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp access_output_shout access_output_rtmp sap slp oldhttp stream_out_standard stream_out_rtp stream_out_raop vod_rtsp access_realrtsp rtp oldtelnet oldrc netsync gnutls growl_udp flac ts audioscrobbler lua remoteosd zvbi audiobargraph_a],[-lws2_32])
-        VLC_ADD_LIBS([filesystem], [-lshlwapi])
-        dnl
-        dnl DEP and ASLR options
-        dnl
-        VLC_FEATURE_DEFAULT_ENABLE([peflags])
-        VLC_FEATURE_OPTION([peflags], [peflags use], [enabled on Windows])
-        AS_IF([VLC_FEATURE_ENABLED([peflags])], [
-          AC_CHECK_TOOL(PEFLAGS, peflags, :)
-        ])
-    else
-      VLC_FEATURE_DEFAULT_DISABLE([peflags])
-    fi
-    if test "${SYS}" = "mingwce"; then
-        # add ws2 for closesocket, select, recv
-        VLC_ADD_LIBS([libvlccore access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp access_output_rtmp sap oldhttp netsync audioscrobbler growl rtp stream_out_rtp remoteosd ts oldtelnet audiobargraph_a],[-lws2])
-        VLC_ADD_LIBS([libvlccore],[-lmmtimer])
-   fi
-    ;;
-  *nto*)
-    SYS=nto
-    ;;
-  solaris*)
-    SYS=solaris
-    ;;
-  hpux*)
-    SYS=hpux
-    ;;
-  beos)
-    SYS=beos
+    # add ws2 for closesocket, select, recv
+    VLC_ADD_LIBS([libvlccore access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp access_output_rtmp sap oldhttp netsync audioscrobbler growl rtp stream_out_rtp remoteosd ts oldtelnet audiobargraph_a],[-lws2])
+    VLC_ADD_LIBS([libvlccore],[-lmmtimer])
+  ],
+  [mingw32], [
+    AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
+
+    # add ws2_32 for closesocket, select, recv
+    VLC_ADD_LIBS([libvlccore],[-lws2_32 -lnetapi32 -lwinmm])
+    VLC_ADD_LDFLAGS([vlc],[-mwindows])
+    VLC_ADD_LIBS([activex mozilla],[-lgdi32])
+    VLC_ADD_LIBS([cdda vcdx sdl_image aout_sdl vout_sdl],[-lwinmm])
+    VLC_ADD_LIBS([access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp access_output_shout access_output_rtmp sap slp oldhttp stream_out_standard stream_out_rtp stream_out_raop vod_rtsp access_realrtsp rtp oldtelnet oldrc netsync gnutls growl_udp flac ts audioscrobbler lua remoteosd zvbi audiobargraph_a],[-lws2_32])
+    VLC_ADD_LIBS([filesystem], [-lshlwapi])
+    VLC_FEATURE_DEFAULT_ENABLE([peflags])
+  ],
+  [beos], [
     CFLAGS_save="${CFLAGS_save} -Wno-multichar"; CFLAGS="${CFLAGS_save}"
     CXXFLAGS_save="${CXXFLAGS_save} -Wno-multichar"; CXXFLAGS="${CXXFLAGS_save}"
     VLC_ADD_CXXFLAGS([beos],[])
@@ -342,11 +296,9 @@ case "${host_os}" in
     else
         VLC_ADD_LIBS([filesystem access_ftp access_mms access_output_udp oldtelnet netsync sap libvlccore growl_udp],[-lnet])
     fi
-    ;;
-  *)
-    SYS="${host_os}"
-    ;;
-esac
+  ]
+)
+
 AM_CONDITIONAL(HAVE_BEOS, test "${SYS}" = "beos")
 AM_CONDITIONAL(HAVE_DARWIN, test "${SYS}" = "darwin")
 AM_CONDITIONAL(HAVE_LINUX, [test "${SYS}" = "linux"])
@@ -856,6 +808,14 @@ AC_ARG_VAR(PKG_CONFIG_PATH,
 	   [Paths where to find .pc not at the default location])
 PKG_PROG_PKG_CONFIG()
 
+dnl windres and objcopy for windows
+AS_CASE(["${SYS}"],
+  [mingw*], [
+    AC_CHECK_TOOL(WINDRES, windres, :)
+    AC_CHECK_TOOL(OBJCOPY, objcopy, :)
+  ]
+)
+
 dnl On some OS we need static linking 
        AS_IF([test -n "${PKG_CONFIG}" ],[
 	      AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce" -o "${SYS}" = "darwin" ],[
@@ -889,6 +849,13 @@ then
 fi
 AM_CONDITIONAL(HAVE_MINIZIP, [ test "${have_minizip}" = "yes" ])
 
+dnl
+dnl DEP and ASLR options
+dnl
+VLC_FEATURE_OPTION([peflags], [peflags use], [enabled on Windows])
+AS_IF([VLC_FEATURE_ENABLED([peflags])], [
+  AC_CHECK_TOOL(PEFLAGS, peflags, :)
+])
 
 dnl Check for dbus
 AS_CASE(
diff --git a/m4/vlc_system.m4 b/m4/vlc_system.m4
new file mode 100644
index 0000000..7b99a0c
--- /dev/null
+++ b/m4/vlc_system.m4
@@ -0,0 +1,29 @@
+dnl Handling system specific things.
+
+AC_DEFUN([VLC_CHECK_SYS], [
+  AS_CASE(["${host_os}"],
+    [""], [SYS="unknown"],
+    [linux*], [SYS="linux"],
+    [bsdi*], [SYS="bsdi"],
+    [*bsd*], [SYS="bsd"],
+    [darwin*], [SYS="darwin"],
+    [*wince* | *mingwce* | *mingw32ce*], [SYS="mingwce"],
+    [*mingw32*], [SYS="mingw32"],
+    [*cygwin*], [
+      dnl Check if we are using the mno-cygwin mode in which case we are
+      dnl actually dealing with a mingw32 compiler.
+      AC_EGREP_CPP([yes],
+        [#ifdef WIN32
+         yes
+         #endif],
+        [SYS=mingw32],
+        [AC_MSG_ERROR([VLC requires -mno-cygwin])]
+      )
+    ],
+    [*nto*], [SYS="nto"],
+    [solaris*], [SYS="solaris"],
+    [hpux*], [SYS="hpux"],
+    [beos], [SYS="beos"],
+    [SYS="${host_os}"]
+  )
+])
-- 
1.6.6.1


From 097f732223746b642aa28c3e74412c73e922edc9 Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Sat, 30 Jan 2010 18:44:31 +0100
Subject: [PATCH 04/10] Remove obsolete Mac OS X 10.5 tweak.

This is obsolete according to IRC conversation. But I also think it got
never really executed, code like "case foo in fo*) a ;; foo*) b ;; esac"
would never lead to b in the shells i've tested.

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/configure.ac b/configure.ac
index 909122d..d54e59d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,26 +242,6 @@ AS_CASE(["${SYS}"],
         export MACOSX_DEPLOYMENT_TARGET
     ])
   ],
-  [darwin9*], [
-    if test "${host_cpu}" = "i386"; then
-        dnl Due to a ld(64) bug in 10.5 we cannot use our mmx code
-        dnl without hacking it a lot, we disable mmx and sse.
-        dnl (that bug is about ld being unable to handle
-        dnl text relocation)
-        save_cflags="$CFLAGS"
-        CFLAGS="$CFLAGS -dynamiclib -single_module -read_only_relocs suppress"
-        AC_TRY_LINK(
-            [int a;], [asm("movq _a,%mm0\n");],
-            ac_ld_does_not_support_text_reloc=no,
-            ac_ld_does_not_support_text_reloc=yes)
-        CFLAGS="$save_cflags"
-
-        if test "x$ac_ld_does_not_support_text_reloc" = "xyes"; then
-            VLC_FEATURE_FORCE_DISABLE([mmx], [due to a bug in ld])
-            VLC_FEATURE_FORCE_DISABLE([sse], [due to a bug in ld])
-        fi
-    fi
-  ],
   [mingwce], [
     dnl Sadly CeGCC still needs non-wince macros
     AC_DEFINE([_WIN32_WINNT], 0x0501, [Define to '0x0500' for Windows 2000 APIs.])
-- 
1.6.6.1


From 36c2141b7406e8752199cb77309bb74a78f61f5e Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Thu, 28 Jan 2010 10:25:32 +0100
Subject: [PATCH 05/10] Add macro to check compiler flags.


Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac       |  294 +++++++++++++++++-----------------------------------
 m4/vlc_common.m4   |    8 ++
 m4/vlc_compiler.m4 |   73 +++++++++++++
 3 files changed, 174 insertions(+), 201 deletions(-)
 create mode 100644 m4/vlc_common.m4
 create mode 100644 m4/vlc_compiler.m4

diff --git a/configure.ac b/configure.ac
index d54e59d..6368eed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,21 +119,16 @@ AS_IF([VLC_FEATURE_ENABLED([contrib])], [
     AC_MSG_RESULT([yes])
     AC_SUBST(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"
+    APPEND_CPPFLAGS([-I${CONTRIB_DIR}/include])
+    APPEND_CFLAGS([-I${CONTRIB_DIR}/include])
+    APPEND_CXXFLAGS([-I${CONTRIB_DIR}/include])
+    APPEND_OBJCFLAGS([-I${CONTRIB_DIR}/include])
+    APPEND_LDFLAGS([-L${CONTRIB_DIR}/lib])
     if test $build = $host -o "$PKG_CONFIG_LIBDIR"; then
         export PKG_CONFIG_PATH=${CONTRIB_DIR}/lib/pkgconfig:$PKG_CONFIG_PATH
     else
         export PKG_CONFIG_LIBDIR=${CONTRIB_DIR}/lib/pkgconfig
     fi
-    LDFLAGS="${LDFLAGS} -L${CONTRIB_DIR}/lib"
-    LDFLAGS_save="${LDFLAGS_save} -L${CONTRIB_DIR}/lib"
 
     have_contrib_libs="yes"
 
@@ -162,31 +157,27 @@ VLC_CHECK_SYS()
 VLC_FEATURE_DEFAULT_DISABLE([peflags])
 AS_CASE(["${SYS}"], 
   [bsdi], [
-    CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
+    APPEND_CFLAGS([-pthread])
     VLC_ADD_LIBS([dvd dvdcss vcd cdda vcdx],[-ldvd])
   ],
   [bsd], [
-    CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
+    APPEND_CFLAGS([-pthread])
     AS_CASE(["${host_os}"],
       [freebsd*], [
-        CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include"
-        CPPFLAGS="${CPPFLAGS_save}"
-        LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib"
-        LDFLAGS="${LDFLAGS_save}"
+        APPEND_CPPFLAGS([-I/usr/local/include])
+        APPEND_LDFLAGS([-L/usr/local/lib])
       ],
       [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}"
+        APPEND_CPPFLAGS([-I/usr/local/include -I/usr/X11R6/include])
+        APPEND_LDFLAGS([-L/usr/local/include -L/usr/X11R6/lib])
       ]
     )
   ],
   [darwin], [
-    CFLAGS_save="${CFLAGS_save} -D_INTL_REDIRECT_MACROS"; CFLAGS="${CFLAGS_save}"
-    CXXFLAGS_save="${CXXFLAGS_save} -D_INTL_REDIRECT_MACROS"; CXXFLAGS="${CXXFLAGS_save}"
-    OBJCFLAGS_save="${OBJCFLAGS_save} -D_INTL_REDIRECT_MACROS -std=gnu99"; OBJCFLAGS="${OBJCFLAGS_save}"
-    LDFLAGS_save="${LDFLAGS_save} -Wl,-headerpad_max_install_names"; LDFLAGS="${LDFLAGS_save}"
+    APPEND_CFLAGS([-D_INTL_REDIRECT_MACROS])
+    APPEND_CXXFLAGS([-D_INTL_REDIRECT_MACROS])
+    APPEND_OBJCFLAGS([-D_INTL_REDIRECT_MACROS])
+    APPEND_LDFLAGS([-Wl,-headerpad_max_install_names])
     VLC_ADD_LDFLAGS([mkv mp4 motion], [-Wl,-framework,IOKit,-framework,CoreFoundation])
     VLC_ADD_LDFLAGS([libvlc vlc],[-Wl,-undefined,dynamic_lookup])
     VLC_ADD_LDFLAGS([avcodec avformat access_avio swscale postproc i420_rgb_mmx x264],[-Wl,-read_only_relocs,suppress])
@@ -235,9 +226,9 @@ AS_CASE(["${SYS}"],
         CXX="${CXX} -mmacosx-version-min=${vlc_string_macosx_version_min}"
         OBJC="${OBJC} -mmacosx-version-min=${vlc_string_macosx_version_min}"
         LD="${LD} -macosx_version_min=${vlc_string_macosx_version_min}"
-        CFLAGS_save="${CFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}"; CFLAGS="${CFLAGS_save}"
-        CXXFLAGS_save="${CXXFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}"; CXXFLAGS="${CXXFLAGS_save}"
-        OBJCFLAGS_save="${OBJCFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}"; OBJCFLAGS="${OBJCFLAGS_save}"
+        APPEND_CFLAGS([-DMACOSX_DEPLOYMENT_TARGET=${use_macosx_version_min}])
+        APPEND_CXXFLAGS([-DMACOSX_DEPLOYMENT_TARGET=${use_macosx_version_min}])
+        APPEND_OBJCFLAGS([-DMACOSX_DEPLOYMENT_TARGET=${use_macosx_version_min}])
         MACOSX_DEPLOYMENT_TARGET=${vlc_string_macosx_version_min}
         export MACOSX_DEPLOYMENT_TARGET
     ])
@@ -263,13 +254,13 @@ AS_CASE(["${SYS}"],
     VLC_FEATURE_DEFAULT_ENABLE([peflags])
   ],
   [beos], [
-    CFLAGS_save="${CFLAGS_save} -Wno-multichar"; CFLAGS="${CFLAGS_save}"
-    CXXFLAGS_save="${CXXFLAGS_save} -Wno-multichar"; CXXFLAGS="${CXXFLAGS_save}"
+    APPEND_CFLAGS([-Wno-multichar])
+    APPEND_CXXFLAGS([-Wno-multichar])
     VLC_ADD_CXXFLAGS([beos],[])
     VLC_ADD_LIBS([vlc libvlccore logger],[-lbe])
     VLC_ADD_LIBS([dvdnav dvdread],[-ldl])
     VLC_ADD_LIBS([filesystem],[-lpoll])
-    LDFLAGS_save="${LDFLAGS_save} -lintl"; LDFLAGS="${LDFLAGS_save}"
+    APPEND_LDFLAGS([-lintl])
     dnl Check for BONE
     if test -f /boot/beos/system/lib/libbind.so; then
         VLC_ADD_LIBS([filesystem access_ftp access_mms access_output_udp oldtelnet netsync sap libvlccore growl_udp],[-lbind -lsocket])
@@ -356,58 +347,18 @@ AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"], [
         AC_MSG_ERROR([LibVLC requires mingw-runtime version 3.15 or higher!])
 ])
     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"
+    APPEND_CPPFLAGS([-D__USE_MINGW_ANSI_STDIO=1])
 ])
 
-dnl Check for the need to include the mingwex lib for mingw32
-if test "${SYS}" = "mingw32"
-then
-    AC_CHECK_LIB(mingwex,opendir,
-        AC_CHECK_LIB(mingw32,opendir,,
-            [VLC_ADD_LIBS([libvlccore],[-lmingwex])])
-    )
-fi
-
-dnl Check for fnative-struct or mms-bitfields support for mingw32
 if test "${SYS}" = "mingw32"
 then
-    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_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
-    fi
-
-    CFLAGS="${CFLAGS_save}"; CXXFLAGS="${CXXFLAGS_save}"
-fi
-
-dnl Check for fvtable-thunks support for mingw32
-if test "${SYS}" = "mingw32" -a "${CXX}" != ""
-then
-AC_LANG_PUSH(C++)
-    AC_CACHE_CHECK([if \$CXX accepts -fvtable-thunks],
-        [ac_cv_cxx_fvtable_thunks],
-        [CXXFLAGS="${CXXFLAGS_save} -Wall -Werror -fvtable-thunks"
-         AC_TRY_COMPILE([],,ac_cv_cxx_fvtable_thunks=yes,
-                        ac_cv_cxx_fvtable_thunks=no)])
-    if test "${ac_cv_cxx_fvtable_thunks}" = "yes"; then
-        CXXFLAGS_mingw32_special="-fvtable-thunks"
-    fi
+  dnl Check for the need to include the mingwex lib for mingw32
+  AC_CHECK_LIB([mingwex], [opendir], [
+    AC_CHECK_LIB([mingw32], [opendir],, [
+      VLC_ADD_LIBS([libvlccore],[-lmingwex])
+    ])
+  ])
 
-    CXXFLAGS_save="${CXXFLAGS_save} ${CXXFLAGS_mingw32_special}"; CXXFLAGS="${CXXFLAGS_save}"
-AC_LANG_POP(C++)
 fi
 
 dnl
@@ -903,109 +854,67 @@ AS_IF([VLC_FEATURE_ENABLED([warnings-as-error])], [
 ])
 AC_SUBST(CFLAGS_WERROR)
 
-dnl Check for various optimization flags
-AC_CACHE_CHECK([if \$CC accepts -Os],
-    [ac_cv_c_os],
-    [CFLAGS="${CFLAGS_save} -Os"
-     AC_TRY_COMPILE([],,ac_cv_c_os=yes, ac_cv_c_os=no)])
-if test "${ac_cv_c_os}" != "no"; then
-    CFLAGS_OPTIM_SIZE="${CFLAGS_OPTIM_SIZE} -Os"
-else
-    AC_CACHE_CHECK([if \$CC accepts -O],
-        [ac_cv_c_o],
-        [CFLAGS="${CFLAGS_save} -O"
-         AC_TRY_COMPILE([],,ac_cv_c_o=yes, ac_cv_c_o=no)])
-    if test "${ac_cv_c_o}" != "no"; then
-        if test "${ac_cv_c_o3}" = "no"; then
-            CFLAGS_OPTIM_SIZE="${CFLAGS_OPTIM_SIZE} -O"
-        fi
-    fi
-fi
+dnl
+dnl Check compiler flags
+dnl Only add -O4 and -O3 to CFLAGS_OPTIM_SPEED if debug is disabled
+dnl
+AS_IF([test "x${SYS}" = "xmingw32"], [
+  dnl Check for fnative-struct or mms-bitfields support for mingw32
+  COMPILEFLAG_CHECK([-mms-bitfields],, [
+    APPEND_CFLAGS([-mms-bitfields])
+    APPEND_CXXFLAGS([-mms-bitfields])
+  ], [
+    COMPILEFLAG_CHECK([-fnative-struct],, [
+      APPEND_CFLAGS([-fnative-struct])
+      APPEND_CXXFLAGS([-fnative-struct])
+    ])
+  ])
 
-AC_CACHE_CHECK([if \$CC accepts -O4],
-    [ac_cv_c_o4],
-    [CFLAGS="${CFLAGS_save} -O4"
-     AC_TRY_COMPILE([],,ac_cv_c_o4=yes, ac_cv_c_o4=no)])
-if test "${ac_cv_c_o4}" != "no" && VLC_FEATURE_DISABLED([debug]); then
-    CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O4"
-else
-    AC_CACHE_CHECK([if \$CC accepts -O3],
-        [ac_cv_c_o3],
-        [CFLAGS="${CFLAGS_save} -O3"
-         AC_TRY_COMPILE([],,ac_cv_c_o3=yes, ac_cv_c_o3=no)])
-    if test "${ac_cv_c_o3}" != "no" && VLC_FEATURE_DISABLED([debug]); then
-        CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O3"
-    else
-        AC_CACHE_CHECK([if \$CC accepts -O2],
-            [ac_cv_c_o2],
-            [CFLAGS="${CFLAGS_save} -O2"
-             AC_TRY_COMPILE([],,ac_cv_c_o2=yes, ac_cv_c_o2=no)])
-        if test "${ac_cv_c_o2}" != "no"; then
-            CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O2"
-        else
-            AC_CACHE_CHECK([if \$CC accepts -O],
-                [ac_cv_c_o],
-                [CFLAGS="${CFLAGS_save} -O"
-                 AC_TRY_COMPILE([],,ac_cv_c_o=yes, ac_cv_c_o=no)])
-            if test "${ac_cv_c_o}" != "no"; then
-                CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O"
-            fi
-        fi
-    fi
-fi
+  dnl Check for fvtable-thunks support for mingw32
+  AC_LANG_PUSH([C++])
+  CXXFLAGS="${CXXFLAGS_save} -Wall -Werror"
+  COMPILEFLAG_CHECK([-fvtable-thunks],, [APPEND_CXXFLAGS([-fvtable-thunks])])
+  AC_LANG_POP([C++])
+])
 
-AC_CACHE_CHECK([if \$CC accepts -O0],
-    [ac_cv_c_o0],
-    [CFLAGS="${CFLAGS_save} -O0"
-     AC_TRY_COMPILE([],,ac_cv_c_o0=yes, ac_cv_c_o0=no)])
-if test "${ac_cv_c_o0}" != "no"; then
-    CFLAGS_NOOPTIM="${CFLAGS_NOOPTIM} -O0"
-fi
+COMPILEFLAG_CHECK([-Os],, [APPEND_VAR([CFLAGS_OPTIM_SIZE], [-Os])], [
+  COMPILEFLAG_CHECK([-O],, [APPEND_VAR([CFLAGS_OPTIM_SIZE], [-O])])
+])
 
-dnl Check for -ffast-math
-AC_CACHE_CHECK([if \$CC accepts -ffast-math],
-    [ac_cv_c_fast_math],
-    [CFLAGS="${CFLAGS_save} -ffast-math"
-     AC_TRY_COMPILE([],,ac_cv_c_fast_math=yes, ac_cv_c_fast_math=no)])
-if test "${ac_cv_c_fast_math}" != "no"; then
-    CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -ffast-math"
-fi
+AS_IF([VLC_FEATURE_DISABLED([debug])], [
+  COMPILEFLAG_CHECK([-O4],, [APPEND_VAR([CFLAGS_OPTIM_SPEED], [-O4])], [
+    COMPILEFLAG_CHECK([-O3],, [APPEND_VAR([CFLAGS_OPTIM_SPEED], [-O3])])
+  ])
+])
+
+dnl Add -O2 or -O even if debug is enabled
+AS_IF([test "x${ac_cv_compflag__o4}" = "xno" && test "x${ac_cv_compflag__o3}" = "xno"], [
+  COMPILEFLAG_CHECK([-O2],, [APPEND_VAR([CFLAGS_OPTIM_SPEED], [-O2])], [
+    COMPILEFLAG_CHECK([-O],, [APPEND_VAR([CFLAGS_OPTIM_SPEED], [-O])])
+  ])
+])
+
+COMPILEFLAG_CHECK([-O0],, [APPEND_VAR([CFLAGS_NOOPTIM], [-O0])])
+COMPILEFLAG_CHECK([-ffast-math],, [APPEND_VAR([CFLAGS_OPTIM_SPEED], [-ffast-math])])
 
-dnl Check for -funroll-loops
 dnl Disabled on BeOS because BeOS' gcc is buggy and may crash with it
-if test "${SYS}" != "beos"
-then
-  AC_CACHE_CHECK([if \$CC accepts -funroll-loops],
-      [ac_cv_c_unroll_loops],
-      [CFLAGS="${CFLAGS_save} -funroll-loops"
-       AC_TRY_COMPILE([],,ac_cv_c_unroll_loops=yes, ac_cv_c_unroll_loops=no)])
-  if test "${ac_cv_c_unroll_loops}" != "no"; then
-      CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -funroll-loops"
-  fi
-fi
+AS_IF([test "x${SYS}" != "xbeos"], [
+  COMPILEFLAG_CHECK([-funroll-loops],, [APPEND_VAR([CFLAGS_OPTIM_SPEED], [-funroll-loops])])
+])
 
-dnl Check for -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_TRY_COMPILE([],,ac_cv_c_omit_frame_pointer=yes, ac_cv_c_omit_frame_pointer=no)])
-if test "${ac_cv_c_omit_frame_pointer}" != "no"; then
- if test "${SYS}" != "darwin"; then
-    CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fomit-frame-pointer"
- else
+COMPILEFLAG_CHECK([-fomit-frame-pointer],, [
+  AS_IF([test "x${SYS}" = "xdarwin"], [
+    APPEND_VAR([CFLAGS_OPTIM_NODEBUG], [-fomit-frame-pointer])
+  ], [
     dnl On darwin we explicitely disable it.
-    CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fno-omit-frame-pointer"
- fi
-fi
+    APPEND_VAR([CFLAGS_OPTIM_NODEBUG], [-fno-omit-frame-pointer])
+  ])
+])
 
 dnl Check for Darwin plugin linking flags
-AC_CACHE_CHECK([if \$CC accepts -bundle -undefined error],
-    [ac_cv_ld_darwin],
-    [CFLAGS="${CFLAGS_save} -bundle -undefined error"
-     AC_TRY_COMPILE([],,ac_cv_ld_darwin=yes, ac_cv_ld_darwin=no)])
-if test "${ac_cv_ld_darwin}" != "no"; then
-    VLC_ADD_LDFLAGS([plugin],[-bundle -undefined error])
-fi
+COMPILEFLAG_CHECK([-bundle -undefined error],, [
+  VLC_ADD_LDFLAGS([plugin], [-bundle -undefined error])
+])
 
 dnl Checks for __attribute__(aligned()) directive
 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
@@ -1427,19 +1336,16 @@ AS_IF([VLC_STRING_SET([tuning])], [
 ])
 
 dnl NOTE: this can't be cached cleanly
-AS_IF([test "${CFLAGS_TUNING}"],
-   [CFLAGS_save="${CFLAGS}"
-    CFLAGS="${CFLAGS} ${CFLAGS_TUNING}"
-
-    AC_MSG_CHECKING([whether $CC accepts ${CFLAGS_TUNING}])
-    AC_COMPILE_IFELSE([ ],
-                      [tuning="yes"],
-                      [CFLAGS_TUNING=""; tuning="no"
-                       AS_IF([VLC_STRING_SET([with-tuning])],
-                             [AC_MSG_ERROR([requested tuning not supported])])])
-
-    AC_MSG_RESULT([$tuning])
-    CFLAGS="${CFLAGS_save}"
+AS_IF([test "${CFLAGS_TUNING}"], [
+  CFLAGS="${CFLAGS} ${CFLAGS_TUNING}"
+
+  COMPILEFLAG_CHECK([${CFLAGS_TUNING}], [tuning],, [
+    AS_IF([VLC_STRING_SET([tuning])], [
+      AC_MSG_ERROR([requested tuning not supported])
+    ])
+  ])
+
+  CFLAGS="${CFLAGS_save}"
 ])
 
 dnl
@@ -1492,13 +1398,9 @@ dnl  Test coverage
 dnl
 VLC_FEATURE_OPTION([coverage], [build for test coverage], [disabled])
 AS_IF([VLC_FEATURE_ENABLED([coverage])], [
-	CFLAGS="-fprofile-arcs -ftest-coverage ${CFLAGS}"
-	CXXFLAGS="-fprofile-arcs -ftest-coverage ${CXXFLAGS}"
-	LDFLAGS="-lgcov ${LDFLAGS}"
-	dnl ugly...
-	CFLAGS_save="${CFLAGS}"
-	CXXFLAGS_save="${CXXFLAGS}"
-	LDFLAGS_save="${LDFLAGS}"
+  PREPEND_CFLAGS([-fprofile-arcs -ftest-coverage])
+  PREPEND_CXXFLAGS([-fprofile-arcs -ftest-coverage])
+  PREPEND_LDFLAGS([-lgcov])
 ])
 
 dnl
@@ -1656,7 +1558,6 @@ AS_IF([VLC_FEATURE_ENABLED([live555])], [
   dnl
   AS_IF([{ VLC_STRING_UNSET([live555-tree]) && test "${CXX}" != "" ;}], [
     AC_LANG_PUSH(C++)
-    CPPFLAGS_save="${CPPFLAGS}"
     CPPFLAGS_live555="-I/usr/include/liveMedia -I/usr/include/groupsock -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment"
     if test "${SYS}" = "solaris"; then
       CPPFLAGS_live555="${CPPFLAGS_live555} -DSOLARIS"
@@ -2248,8 +2149,6 @@ AS_IF([VLC_FEATURE_ENABLED([screen])], [
   elif test "${SYS}" = "mingw32"; then
     VLC_ADD_PLUGIN([screen])
     VLC_ADD_LIBS([screen],[-lgdi32])
-  elif test "${SYS}" = "mingwce"; then
-    CPPFLAGS="${CPPFLAGS_save}"
   elif test "${SYS}" = "beos"; then
     VLC_ADD_PLUGIN([screen])
     VLC_ADD_CXXFLAGS([screen],[])
@@ -2942,7 +2841,6 @@ AS_IF([VLC_FEATURE_ENABLED([x264])], [
       ],[
         AC_MSG_ERROR([the specified tree hasn't been compiled])
       ])
-      LDFLAGS="${LDFLAGS_save}"
     else
       AC_MSG_RESULT(no)
       AC_MSG_ERROR([the specified tree doesn't have x264.h])
@@ -2971,7 +2869,6 @@ AS_IF([VLC_FEATURE_ENABLED([x264])], [
             AC_MSG_ERROR([Could not find libx264 >= 0.76 on your system: you may get it from http://www.videolan.org/x264.html])
           ])
       ])
-    LDFLAGS="${LDFLAGS_save}"
   ])
 ])
 
@@ -3443,9 +3340,6 @@ AS_IF([VLC_FEATURE_ENABLED([directfb])], [
     LIBS_mydirectfb=
     AS_IF([VLC_STRING_SET([directfb])], [
         dnl Trying the given location
-        CPPFLAGS_save="${CPPFLAGS}"
-        LIBS_save="${LIBS}"
-
         CPPFLAGS_new="-I${vlc_string_directfb}/include -D_REENTRANT -D_GNU_SOURCE"
         LIBS_new="-L${vlc_string_directfb}/lib/fusion/.libs/ -L${vlc_string_directfb}/lib/direct/.libs/"
         LIBS_new="${LIBS_new} -L${vlc_string_directfb}/src/.libs/"
@@ -3646,7 +3540,6 @@ VLC_FEATURE_OPTION([cyberlin], [CyberLink for C++ UPnP stack], [disabled])
       AC_MSG_RESULT(no)
       AC_MSG_ERROR([cannot cd to ${try_cyberlink_tree}])
     ])
-    CPPFLAGS_save="${CPPFLAGS}"
     CPPFLAGS_cyberlink="-I${real_cyberlink_tree}/include"
     CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_cyberlink}"
     AC_CHECK_HEADERS([cybergarage/upnp/MediaServer.h],
@@ -3660,7 +3553,6 @@ VLC_FEATURE_OPTION([cyberlin], [CyberLink for C++ UPnP stack], [disabled])
       AC_MSG_RESULT(${real_cyberlink_tree}/lib/unix/libclink.a)
       dnl The mere fact that we have to make such an ugly check sucks
       AC_MSG_CHECKING(for XML parser to link CyberLink with)
-      LIBS_save="$LIBS"
       LIBS_cclink="no"
       for l in "`xml2-config --libs`" -lexpat -lxerces-c; do
         LIBS="$LIBS_save ${real_cyberlink_tree}/lib/unix/libclink.a -lpthread $l"
diff --git a/m4/vlc_common.m4 b/m4/vlc_common.m4
new file mode 100644
index 0000000..d5da041
--- /dev/null
+++ b/m4/vlc_common.m4
@@ -0,0 +1,8 @@
+dnl Common shell foo.
+
+dnl APPEND_VAR(VARNAME, CONTENTS)
+dnl PREPEND_VAR(VARNAME, CONTENTS)
+dnl
+dnl Append or prepend CONTENTS to shell variable VARNAME.
+AC_DEFUN([APPEND_VAR], [$1][="${][$1][} ][$2]["])
+AC_DEFUN([PREPEND_VAR], [$1][="][$2][ ${]$1[}"])
diff --git a/m4/vlc_compiler.m4 b/m4/vlc_compiler.m4
new file mode 100644
index 0000000..a3dd07b
--- /dev/null
+++ b/m4/vlc_compiler.m4
@@ -0,0 +1,73 @@
+dnl Handling compiler specific things of configure.
+
+dnl APPEND_*FLAGS(FLAGS)
+dnl PREPEND_*FLAGS(FLAGS)
+dnl 
+dnl Append or prepend flags to global *FLAGS (*FLAGS and *FLAGS_save).
+AC_DEFUN([APPEND_CPPFLAGS], [
+  APPEND_VAR([CPPFLAGS_save], [$1])
+  CPPFLAGS="${CPPFLAGS_save}"
+])
+AC_DEFUN([APPEND_CFLAGS], [
+  APPEND_VAR([CFLAGS_save], [$1])
+  CFLAGS="${CFLAGS_save}"
+])
+AC_DEFUN([APPEND_CXXFLAGS], [
+  APPEND_VAR([CXXFLAGS_save], [$1])
+  CXXFLAGS="${CXXFLAGS_save}"
+])
+AC_DEFUN([APPEND_OBJCFLAGS], [
+  APPEND_VAR([OBJCFLAGS_save], [$1])
+  OBJCFLAGS="${OBJCFLAGS_save}"
+])
+AC_DEFUN([APPEND_LDFLAGS], [
+  APPEND_VAR([LDFLAGS_save], [$1])
+  LDFLAGS="${LDFLAGS_save}"
+])
+AC_DEFUN([PREPEND_CPPFLAGS], [
+  PREPEND_VAR([CPPFLAGS_save], [$1])
+  CPPFLAGS="${CPPFLAGS_save}"
+])
+AC_DEFUN([PREPEND_CFLAGS], [
+  PREPEND_VAR([CFLAGS_save], [$1])
+  CFLAGS="${CFLAGS_save}"
+])
+AC_DEFUN([PREPEND_CXXFLAGS], [
+  PREPEND_VAR([CXXFLAGS_save], [$1])
+  CXXFLAGS="${CXXFLAGS_save}"
+])
+AC_DEFUN([PREPEND_OBJCFLAGS], [
+  PREPEND_VAR([OBJCFLAGS_save], [$1])
+  OBJCFLAGS="${OBJCFLAGS_save}"
+])
+AC_DEFUN([PREPEND_LDFLAGS], [
+  PREPEND_VAR([LDFLAGS_save], [$1])
+  LDFLAGS="${LDFLAGS_save}"
+])
+
+dnl COMPILEFLAG_CHECK(FLAGS, [CACHE-VARIABLE-SUFFIX], [ACTION-IF], [ACTION-IF-NOT])
+dnl 
+dnl Check if the compiler understands certain flags. Store yes/no
+dnl in ac_cv_compflags_CACHE-VARIABLE-SUFFIX.
+dnl CACHE-VARIABLE-SUFFIX defaults to lowercase FLAGS with '-' and ' '
+dnl substituted by '_'.
+dnl Restores the original _save flags after compiling.
+AC_DEFUN([COMPILEFLAG_CHECK], [
+  m4_pushdef([cvar],
+             [ac_cv_compflags_]m4_default([$2], m4_tolower(m4_bpatsubst($1, [[- ]], [_]))))
+
+  AC_CACHE_CHECK([if \$CC accepts $1], cvar, [
+    APPEND_VAR([CFLAGS], [$1])
+    APPEND_VAR([CXXFLAGS], [$1])
+    APPEND_VAR([OBJCFLAGS], [$1])
+
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], cvar="yes", cvar="no")
+
+    VLC_RESTORE_FLAGS()
+  ])
+
+  AS_IF([test "x${]cvar[}" = "xyes"], [$3], [$4])
+
+  m4_popdef([cvar])
+])
+
-- 
1.6.6.1


From 2dd4e037a2d7eebb4491cb76f87da3197814f8c3 Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Sat, 30 Jan 2010 18:51:07 +0100
Subject: [PATCH 06/10] Put mmx/sse/etc. optimizations handling into separate file.

Also don't globably substitute MMX/SSE/etc. _CFLAGS but put them into
the modules that need 'em.

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac                |  359 ++++++-------------------------------------
 m4/vlc_optimizations.m4     |  356 ++++++++++++++++++++++++++++++++++++++++++
 modules/arm_neon/Modules.am |    2 -
 modules/mmx/Modules.am      |    2 -
 modules/sse2/Modules.am     |    2 -
 5 files changed, 406 insertions(+), 315 deletions(-)
 create mode 100644 m4/vlc_optimizations.m4

diff --git a/configure.ac b/configure.ac
index 6368eed..e3e89a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -942,18 +942,6 @@ if test "${ac_cv_c_attribute_packed}" != "no"; then
   AC_DEFINE(HAVE_ATTRIBUTE_PACKED, 1, Support for __attribute__((packed)) for structs)
 fi
 
-dnl
-dnl  Check the CPU
-dnl
-case "${host_cpu}" in
-  "")
-    ARCH=unknown
-    ;;
-  *)
-    ARCH="${host_cpu}"
-    ;;
-esac
-
 dnl Check for backtrace() support
 AC_CHECK_HEADERS(execinfo.h)
 AC_CHECK_FUNCS(backtrace)
@@ -998,322 +986,75 @@ dnl
 EXTEND_HELP_STRING([])
 EXTEND_HELP_STRING([Optimization options:])
 
-dnl  Check for fully working MMX intrinsics
-dnl  We need support for -mmmx, we need <mmintrin.h>, and we also need a
-dnl  working compiler (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23963)
-AS_CASE(
-  ["${host_cpu}"],
-  [i?86|x86_64], [VLC_FEATURE_DEFAULT_ENABLE([mmx])],
-  [VLC_FEATURE_DEFAULT_DISABLE([mmx])]
+dnl SSE/SSE2 won't work on solaris
+AS_CASE(["${SYS}"],
+  [solaris], [ac_cv_sse_inline="no" ; ac_cv_sse2_inline="no"]
 )
-VLC_FEATURE_OPTION([mmx], [enable MMX optimizations], [auto])
-have_mmx="no"
-have_mmxext="no"
-AS_IF([VLC_FEATURE_ENABLED([mmx])], [
-  ARCH="${ARCH} mmx"
-
-  AC_CACHE_CHECK([if $CC groks MMX intrinsics],
-    [ac_cv_c_mmx_intrinsics],
-    [CFLAGS="${CFLAGS_save} -O -mmmx"
-     AC_TRY_COMPILE([#include <mmintrin.h>
-                     #include <stdint.h>
-                     uint64_t frobzor;],
-                    [__m64 a, b, c;
-                     a = b = c = (__m64)frobzor;
-                     a = _mm_slli_pi16(a, 3);
-                     a = _mm_adds_pi16(a, b);
-                     c = _mm_srli_pi16(c, 8);
-                     c = _mm_slli_pi16(c, 3);
-                     b = _mm_adds_pi16(b, c);
-                     a = _mm_unpacklo_pi8(a, b);
-                     frobzor = (uint64_t)a;],
-                    [ac_cv_c_mmx_intrinsics=yes],
-                    [ac_cv_c_mmx_intrinsics=no])])
-  AS_IF([test "${ac_cv_c_mmx_intrinsics}" != "no"], [
-    AC_DEFINE(HAVE_MMX_INTRINSICS, 1,
-              [Define to 1 if MMX intrinsics are available.])
-    MMX_CFLAGS="-mmmx"
-  ])
 
-  AC_CACHE_CHECK([if $CC groks MMX inline assembly],
-    [ac_cv_mmx_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("packuswb %%mm1,%%mm2"::"r"(p));],
-                    ac_cv_mmx_inline=yes, ac_cv_mmx_inline=no)])
-  AS_IF([test "${ac_cv_mmx_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_MMX, 1,
-              [Define to 1 inline MMX assembly is available.])
-    have_mmx="yes"
-  ])
+VLC_FEATURE_DEFAULT_DISABLE([altivec mmx neon sse])
 
-  AC_CACHE_CHECK([if $CC groks MMX EXT inline assembly],
-    [ac_cv_mmxext_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("maskmovq %%mm1,%%mm2"::"r"(p));],
-                    ac_cv_mmxext_inline=yes, ac_cv_mmxext_inline=no)])
-  AS_IF([test "${ac_cv_mmxext_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_MMXEXT, 1,
-              [Define to 1 if MMX EXT inline assembly is available.])
-    have_mmxext="yes"
-  ])
-])
-AC_SUBST(MMX_CFLAGS)
-AM_CONDITIONAL([HAVE_MMX], [test "${have_mmx}" = "yes"])
-AM_CONDITIONAL([HAVE_MMXEXT], [test "${have_mmxext}" = "yes"])
-
-dnl  Check for fully workin SSE2 intrinsics
-dnl  We need support for -mmmx, we need <emmintrin.h>, and we also need a
-dnl  working compiler (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23963)
-AS_CASE(
-  ["${host_cpu}"],
-  [i686|x86_64], [VLC_FEATURE_DEFAULT_ENABLE([sse])],
-  [VLC_FEATURE_DEFAULT_DISABLE([sse])]
+dnl Enable optimization based on CPU
+AS_CASE(["${host_cpu}"],
+  [powerpc], [VLC_FEATURE_DEFAULT_ENABLE([altivec])],
+  [arm], [VLC_FEATURE_DEFAULT_ENABLE([neon])],
+  [i686|x86_64], [VLC_FEATURE_DEFAULT_ENABLE([mmx sse])],
+  [i?86], [VLC_FEATURE_DEFAULT_ENABLE([mmx])]
 )
-VLC_FEATURE_OPTION([sse], [enable SSE (1, 2, 3 and 4) optimizations], [auto])
-have_sse2="no"
-AS_IF([VLC_FEATURE_ENABLED([sse])], [
-  ARCH="${ARCH} sse sse2"
-
-  AC_CACHE_CHECK([if $CC groks SSE2 intrinsics],
-    [ac_cv_c_sse2_intrinsics],
-    [CFLAGS="${CFLAGS_save} -O -msse2"
-     AC_TRY_COMPILE([#include <emmintrin.h>
-                     #include <stdint.h>
-                     uint64_t frobzor;],
-                    [__m128i a, b, c;
-                     a = b = c = _mm_set1_epi64((__m64)frobzor);
-                     a = _mm_slli_epi16(a, 3);
-                     a = _mm_adds_epi16(a, b);
-                     c = _mm_srli_epi16(c, 8);
-                     c = _mm_slli_epi16(c, 3);
-                     b = _mm_adds_epi16(b, c);
-                     a = _mm_unpacklo_epi8(a, b);
-                     frobzor = (uint64_t)_mm_movepi64_pi64(a);],
-                    [ac_cv_c_sse2_intrinsics=yes],
-                    [ac_cv_c_sse2_intrinsics=no])])
-  AS_IF([test "${ac_cv_c_sse2_intrinsics}" != "no"], [
-    AC_DEFINE(HAVE_SSE2_INTRINSICS, 1,
-              [Define to 1 if SSE2 intrinsics are available.])
-    SSE2_CFLAGS="-msse2"
-  ])
 
-  AC_CACHE_CHECK([if $CC groks SSE inline assembly],
-    [ac_cv_sse_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("xorps %%xmm1,%%xmm2"::"r"(p));],
-                    ac_cv_sse_inline=yes, ac_cv_sse_inline=no)])
-  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.])
-  ])
+AS_CASE(["${host_cpu}"],
+  [""], [ARCH="unknown"],
+  [ARCH="${host_cpu}"]
+)
 
-  AC_CACHE_CHECK([if $CC groks SSE2 inline assembly],
-    [ac_cv_sse2_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("punpckhqdq %%xmm1,%%xmm2"::"r"(p));],
-                    ac_cv_sse2_inline=yes, ac_cv_sse2_inline=no)])
-  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.])
-    have_sse2="yes"
-  ])
+dnl Set and extend ARCH
+AS_IF([VLC_FEATURE_ENABLED([altivec])], [ARCH="${ARCH} altivec"])
+AS_IF([VLC_FEATURE_ENABLED([mmx])], [ARCH="${ARCH} mmx"])
+AS_IF([VLC_FEATURE_ENABLED([sse])], [ARCH="${ARCH} sse sse2"])
 
-  # SSE3
-  AC_CACHE_CHECK([if $CC groks SSE3 inline assembly],
-    [ac_cv_sse3_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("movsldup %%xmm1,%%xmm0"::"r"(p));],
-                    ac_cv_sse3_inline=yes, ac_cv_sse3_inline=no)])
-  AS_IF([test "${ac_cv_sse3_inline}" != "no"], [
-    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}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("pabsw %%xmm0,%%xmm0"::"r"(p));],
-                    ac_cv_ssse3_inline=yes, ac_cv_ssse3_inline=no)])
-  AS_IF([test "${ac_cv_ssse3_inline}" != "no"], [
-    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}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("pmaxsb %%xmm1,%%xmm0"::"r"(p));],
-                    ac_cv_sse4_1_inline=yes, ac_cv_sse4_1_inline=no)])
-  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.]) ])
-
-  # SSE4.2
-  AC_CACHE_CHECK([if $CC groks SSE4.2 inline assembly],
-    [ac_cv_sse4_2_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("pcmpgtq %%xmm1,%%xmm0"::"r"(p));],
-                    ac_cv_sse4_2_inline=yes, ac_cv_sse4_2_inline=no)])
-  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.]) ])
-
-  # SSE4A
-  AC_CACHE_CHECK([if $CC groks SSE4A inline assembly],
-    [ac_cv_sse4a_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("insertq %%xmm1,%%xmm0"::"r"(p));],
-                    ac_cv_sse4a_inline=yes, ac_cv_sse4a_inline=no)])
-  AS_IF([test "${ac_cv_sse4a_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_SSE4A, 1,
-              [Define to 1 if SSE4A inline assembly is available.]) ])
-])
-AC_SUBST(SSE2_CFLAGS)
-AM_CONDITIONAL([HAVE_SSE2], [test "$have_sse2" = "yes"])
-
-have_3dnow="no"
-AC_CACHE_CHECK([if $CC groks 3D Now! inline assembly],
-    [ac_cv_3dnow_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[void *p;asm volatile("pfadd %%mm1,%%mm2"::"r"(p));],
-                    ac_cv_3dnow_inline=yes, ac_cv_3dnow_inline=no)])
-AS_IF([test "${ac_cv_3dnow_inline}" != "no"], [
-  AC_DEFINE(CAN_COMPILE_3DNOW, 1,
-            [Define to 1 if 3D Now! inline assembly is available.])
-  have_3dnow="yes"
-])
-AM_CONDITIONAL([HAVE_3DNOW], [test "$have_3dnow" = "yes"])
-
-AS_IF([test "x${host_cpu}" = "xarm"], [
-  VLC_FEATURE_DEFAULT_ENABLE([neon])
-], [
-  VLC_FEATURE_DEFAULT_DISABLE([neon])
-])
+VLC_CHECK_MMX()
+VLC_CHECK_SSE()
+VLC_CHECK_3DNOW()
+VLC_CHECK_NEON()
+VLC_CHECK_ALTIVEC()
 
-VLC_FEATURE_OPTION([neon], [enable NEON optimizations], [auto])
-AS_IF([VLC_FEATURE_ENABLED([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");]])
-    ], [
-      ac_cv_neon_inline="-mfpu=neon"
-    ], [
-      ac_cv_neon_inline="no"
+dnl Actions based on enabled optimizations
+AS_IF([test "x${SYS}" = "xdarwin"], [
+  AS_IF([VLC_FEATURE_ENABLED([altivec])], [
+    AC_CACHE_CHECK([if linker needs -framework vecLib], [ac_cv_ld_altivec], [
+      LDFLAGS="${LDFLAGS_vlc} -Wl,-framework,vecLib"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM()], [ac_cv_ld_altivec="yes"],
+                     [ac_cv_ld_altivec="no"])
+      LDFLAGS="${LDFLAGS_vlc}"
     ])
-    CFLAGS="${CFLAGS_save}"
-  ])
-  ARM_NEON_CFLAGS="$ac_cv_neon_inline"
-], [
-  ac_cv_neon_inline="no"
-])
-AC_SUBST(ARM_NEON_CFLAGS)
-AM_CONDITIONAL(HAVE_ARM_NEON, [test "${ac_cv_neon_inline}" != "no"])
 
-AS_IF([test "x${host_cpu}" = "xpowerpc"], [
-  VLC_FEATURE_DEFAULT_ENABLE([altivec])
-], [
-  VLC_FEATURE_DEFAULT_DISABLE([altivec])
-])
-VLC_FEATURE_OPTION([altivec], [enable AltiVec optimizations], [auto])
-have_altivec="no"
-AS_IF([VLC_FEATURE_ENABLED([altivec])], [
-  ARCH="${ARCH} altivec";
-  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_cv_altivec_inline="yes",
-         [CFLAGS="${CFLAGS_save} -Wa,-m7400"
-          AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
-            [ac_cv_altivec_inline="-Wa,-m7400"],
-            ac_cv_altivec_inline=no)
-         ])])
-  AS_IF([test "${ac_cv_altivec_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_ALTIVEC, 1,
-              [Define to 1 if AltiVec inline assembly is available.])
-    AS_IF([test "${ac_cv_altivec_inline}" != "yes"], [
-      VLC_ADD_CFLAGS([idctaltivec],[${ac_cv_altivec_inline}])
-      VLC_ADD_CFLAGS([motionaltivec],[${ac_cv_altivec_inline}])
-      VLC_ADD_CFLAGS([memcpyaltivec],[${ac_cv_altivec_inline}])
-      VLC_ADD_CFLAGS([i420_yuy2_altivec],[${ac_cv_altivec_inline}])
-      VLC_ADD_CFLAGS([libvlccore],[${ac_cv_altivec_inline}])
+    AS_IF([test "x${ac_cv_ld_altivec}" = "xyes"], [
+      VLC_ADD_LDFLAGS([libvlccore idctaltivec motionaltivec memcpyaltivec],
+                      [-Wl,-framework,vecLib])
     ])
-    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
-  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"
-   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"
-      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"
-         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"
-            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"
-               AC_TRY_COMPILE([#include <altivec.h>],
-                 [vec_ld(0, (unsigned char *)0);],
-                 [ac_cv_c_altivec="-fvec"],
-                 [ac_cv_c_altivec=no])
-              ])
-           ])
-        ])
-     ])
-   CFLAGS="${CFLAGS_save}"
-  ])
-  AS_IF([test "${ac_cv_c_altivec}" != "no"], [
-    CPPFLAGS="${CPPFLAGS_save} ${ac_cv_c_altivec}"
-  ])
+AS_IF([{ VLC_FEATURE_ENABLED([mmx]) && test "x${ac_cv_c_mmx_intrinsics}" = "xyes"; }], [
+  VLC_ADD_CFLAGS([mmx], [-mmmx])
+])
 
-  AC_CHECK_HEADERS(altivec.h)
-  CPPFLAGS="${CPPFLAGS_save}"
+AS_IF([{ VLC_FEATURE_ENABLED([sse]) && test "x${ac_cv_c_sse2_intrinsics}" = "xyes"; }], [
+  VLC_ADD_CFLAGS([sse2], [-msse2])
+])
 
-  AS_IF([test "${ac_cv_c_altivec}" != "no"], [
-    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([idctaltivec motionaltivec],[${ac_cv_c_altivec}])
-    VLC_ADD_CFLAGS([i420_yuy2_altivec memcpyaltivec deinterlace],[${ac_cv_c_altivec} ${ac_cv_c_altivec_abi}])
-    have_altivec="yes"
+dnl Those vars can be set to yes/no/-flagFoo or it can be left uninitialized.
+dnl If it contains -flagFoo, add the specific CFLAGS.
+AS_IF([VLC_FEATURE_ENABLED([neon])], [
+  AS_CASE(["${ac_cv_neon_inline}"], [""|"yes"|"no"], [], [
+    VLC_ADD_CFLAGS([arm_neon], [${ac_cv_neon_inline}])
   ])
+])
 
-  AC_CACHE_CHECK([if linker needs -framework vecLib],
-    [ac_cv_ld_altivec],
-    [LDFLAGS="${LDFLAGS_vlc} -Wl,-framework,vecLib"
-     AC_TRY_LINK([],,ac_cv_ld_altivec=yes,ac_cv_ld_altivec=no)
-     LDFLAGS="${LDFLAGS_save}"
-    ])
-  AS_IF([test "${ac_cv_ld_altivec}" != "no"], [
-    VLC_ADD_LDFLAGS([libvlccore idctaltivec motionaltivec memcpyaltivec],[-Wl,-framework,vecLib])
-  ])
+AS_CASE(["${ac_cv_altivec_inline}"], [""|"yes"|"no"], [], [
+  VLC_ADD_CFLAGS([idctaltivec motionaltivec memcpyaltivec i420_yuv2_altivec libvlccore],
+                 [${ac_cv_altivec_inline}])
 ])
-AM_CONDITIONAL([HAVE_ALTIVEC], [test "$have_altivec" = "yes"])
+
 
 dnl
 dnl  Special arch tuning
diff --git a/m4/vlc_optimizations.m4 b/m4/vlc_optimizations.m4
new file mode 100644
index 0000000..7dc8ff2
--- /dev/null
+++ b/m4/vlc_optimizations.m4
@@ -0,0 +1,356 @@
+dnl Handling optimizations determined by ./configure like mmx/sse/etc.
+
+
+
+dnl  Check for fully working MMX intrinsics
+dnl  We need support for -mmmx, we need <mmintrin.h>, and we also need a
+dnl  working compiler (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23963)
+AC_DEFUN([VLC_CHECK_MMX], [
+  VLC_FEATURE_OPTION([mmx], [enable MMX optimizations], [auto])
+
+  AS_IF([VLC_FEATURE_ENABLED([mmx])], [
+    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>
+                          uint64_t frobzor;]],
+                        [[__m64 a, b, c;
+                          a = b = c = (__m64)frobzor;
+                          a = _mm_slli_pi16(a, 3);
+                          a = _mm_adds_pi16(a, b);
+                          c = _mm_srli_pi16(c, 8);
+                          c = _mm_slli_pi16(c, 3);
+                          b = _mm_adds_pi16(b, c);
+                          a = _mm_unpacklo_pi8(a, b);
+                          frobzor = (uint64_t)a;]])
+      ],
+      [ac_cv_c_mmx_intrinsics="yes"], [ac_cv_c_mmx_intrinsics="no"])
+      CFLAGS="${CFLAGS_save}"
+    ])
+
+    AS_IF([test "x${ac_cv_c_mmx_intrinsics}" = "xyes"], [
+      AC_DEFINE([HAVE_MMX_INTRINSICS], 1,
+                [Define to 1 if MMX intrinsics are available.])
+    ])
+
+    AC_CACHE_CHECK([if $CC groks MMX inline assembly], [ac_cv_mmx_inline], [
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                           asm volatile("packuswb %%mm1,%%mm2"::"r"(p));]])
+      ],
+      [ac_cv_mmx_inline="yes"], [ac_cv_mmx_inline="no"])
+    ])
+
+    AS_IF([test "x${ac_cv_mmx_inline}" = "xyes"], [
+      have_mmx="yes"
+      AC_DEFINE([CAN_COMPILE_MMX], 1,
+                [Define to 1 inline MMX assembly is available.])
+    ])
+
+    AC_CACHE_CHECK([if $CC groks MMX EXT inline assembly], [ac_cv_mmxext_inline], [
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                           asm volatile("maskmovq %%mm1,%%mm2"::"r"(p));]])
+      ],
+      [ac_cv_mmxext_inline="yes"], [ac_cv_mmxext_inline="no"])
+    ])
+
+    AS_IF([test "x${ac_cv_mmxext_inline}" = "xyes"], [
+      have_mmxext="yes"
+      AC_DEFINE([CAN_COMPILE_MMXEXT], 1,
+                [Define to 1 if MMX EXT inline assembly is available.])
+    ])
+  ])
+
+  AM_CONDITIONAL([HAVE_MMX], [test "x${have_mmx}" = "xyes"])
+  AM_CONDITIONAL([HAVE_MMXEXT], [test "x${have_mmxext}" = "xyes"])
+])
+
+
+
+dnl  Check for fully workin SSE2 intrinsics
+dnl  We need support for -mmmx, we need <emmintrin.h>, and we also need a
+dnl  working compiler (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23963)
+AC_DEFUN([VLC_CHECK_SSE], [
+  VLC_FEATURE_OPTION([sse], [enable SSE (1, 2, 3 and 4) optimizations], [auto])
+
+  AS_IF([VLC_FEATURE_ENABLED([sse])], [
+    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>
+                          uint64_t frobzor;]],
+                        [[__m128i a, b, c;
+                          a = b = c = _mm_set1_epi64((__m64)frobzor);
+                          a = _mm_slli_epi16(a, 3);
+                          a = _mm_adds_epi16(a, b);
+                          c = _mm_srli_epi16(c, 8);
+                          c = _mm_slli_epi16(c, 3);
+                          b = _mm_adds_epi16(b, c);
+                          a = _mm_unpacklo_epi8(a, b);
+                          frobzor = (uint64_t)_mm_movepi64_pi64(a);]])
+      ],
+      [ac_cv_c_sse2_intrinsics=yes], [ac_cv_c_sse2_intrinsics=no])
+      CFLAGS="${CFLAGS_save}"
+    ])
+
+    AS_IF([test "x${ac_cv_c_sse2_intrinsics}" = "xyes"], [
+      AC_DEFINE([HAVE_SSE2_INTRINSICS], 1,
+                [Define to 1 if SSE2 intrinsics are available.])
+    ])
+
+    # SSE1
+    AC_CACHE_CHECK([if $CC groks SSE inline assembly], [ac_cv_sse_inline], [
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                           asm volatile("xorps %%xmm1,%%xmm2"::"r"(p));]])
+      ],
+      [ac_cv_sse_inline="yes"], [ac_cv_sse_inline="no"])
+    ])
+
+    # SSE2
+    AS_IF([test "x${ac_cv_sse_inline}" = "xyes"], [
+      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], [
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                         asm volatile("punpckhqdq %%xmm1,%%xmm2"::"r"(p));]])
+      ],
+      [ac_cv_sse2_inline="yes"], [ac_cv_sse2_inline="no"])
+    ])
+
+    AS_IF([test "x${ac_cv_sse2_inline}" = "xyes"], [
+      have_sse2="yes"
+      AC_DEFINE([CAN_COMPILE_SSE2], 1,
+                [Define to 1 if SSE2 inline assembly is available.])
+    ])
+
+    # SSE3
+    AC_CACHE_CHECK([if $CC groks SSE3 inline assembly], [ac_cv_sse3_inline], [
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                           asm volatile("movsldup %%xmm1,%%xmm0"::"r"(p));]])
+      ],
+      [ac_cv_sse3_inline="yes"], [ac_cv_sse3_inline="no"])
+    ])
+
+    AS_IF([test "x${ac_cv_sse3_inline}" = "xyes"], [
+      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}"
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                           asm volatile("pabsw %%xmm0,%%xmm0"::"r"(p));]])
+      ],
+      [ac_cv_ssse3_inline="yes"], [ac_cv_ssse3_inline="no"])
+    ])
+
+    AS_IF([test "x${ac_cv_ssse3_inline}" = "xyes"], [
+      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}"
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                           asm volatile("pmaxsb %%xmm1,%%xmm0"::"r"(p));]])
+      ],
+      [ac_cv_sse4_1_inline="yes", ac_cv_sse4_1_inline="no"])
+    ])
+
+    AS_IF([test "x${ac_cv_sse4_1_inline}" = "xyes"], [
+      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}"
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                           asm volatile("pcmpgtq %%xmm1,%%xmm0"::"r"(p));]])
+      ],
+      [ac_cv_sse4_2_inline="yes"], [ac_cv_sse4_2_inline="no"])
+    ])
+
+    AS_IF([test "x${ac_cv_sse4_2_inline}" = "xyes"], [
+      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], [
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[void *p;
+                           asm volatile("insertq %%xmm1,%%xmm0"::"r"(p));]])
+      ],
+      [ac_cv_sse4a_inline="yes"], [ac_cv_sse4a_inline="no"])
+    ])
+
+    AS_IF([test "x${ac_cv_sse4a_inline}" = "xyes"], [
+      AC_DEFINE([CAN_COMPILE_SSE4A], 1,
+                [Define to 1 if SSE4A inline assembly is available.])
+    ])
+  ])
+
+  AM_CONDITIONAL([HAVE_SSE2], [test "x${have_sse2}" = "xyes"])
+])
+
+
+
+dnl Check for working 3D Now!
+AC_DEFUN([VLC_CHECK_3DNOW], [
+  AC_CACHE_CHECK([if $CC groks 3D Now! inline assembly], [ac_cv_3dnow_inline], [
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM(,[[void *p;
+                         asm volatile("pfadd %%mm1,%%mm2"::"r"(p));]])
+    ],
+    [ac_cv_3dnow_inline="yes"], [ac_cv_3dnow_inline="no"])
+  ])
+
+  AS_IF([test "x${ac_cv_3dnow_inline}" = "xyes"], [
+    have_3dnow="yes"
+    AC_DEFINE([CAN_COMPILE_3DNOW], 1,
+              [Define to 1 if 3D Now! inline assembly is available.])
+  ])
+
+  AM_CONDITIONAL([HAVE_3DNOW], [test "x${have_3dnow}" = "xyes"])
+])
+
+
+
+dnl Check for working NEON
+AC_DEFUN([VLC_CHECK_NEON], [
+  VLC_FEATURE_OPTION([neon], [enable NEON optimizations], [auto])
+
+  AS_IF([VLC_FEATURE_ENABLED([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");]])
+      ],
+      [ac_cv_neon_inline="-mfpu=neon"], [ac_cv_neon_inline="no"])
+      CFLAGS="${CFLAGS_save}"
+    ])
+
+    AS_IF([test "x${ac_cv_neon_inline}" != "xno"], [
+      have_neon="yes"
+    ])
+  ])
+
+  AM_CONDITIONAL([HAVE_ARM_NEON], [test "x${have_neon}" = "xyes"])
+])
+
+
+
+dnl Check for working AltiVec
+AC_DEFUN([VLC_CHECK_ALTIVEC], [
+  VLC_FEATURE_OPTION([altivec], [enable AltiVec optimizations], [auto])
+
+  AS_IF([VLC_FEATURE_ENABLED([altivec])], [
+    AC_CACHE_CHECK([if $CC groks AltiVec inline assembly], [ac_cv_altivec_inline], [
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM(,[[asm volatile("vperm 0,1,2,3");]])
+      ], [ac_cv_altivec_inline="yes"], [
+        CFLAGS="${CFLAGS_save} -Wa,-m7400"
+        AC_COMPILE_IFELSE([
+          AC_LANG_PROGRAM(,[[asm volatile("vperm 0,1,2,3");]])
+        ], [ac_cv_altivec_inline="-Wa,-m7400"], [ac_cv_altivec_inline="no"])
+        CFLAGS="${CFLAGS_save}"
+      ])
+    ])
+
+    AS_IF([test "x${ac_cv_altivec_inline}" != "xno"], [
+      have_altivec="yes"
+      AC_DEFINE([CAN_COMPILE_ALTIVEC], 1,
+                [Define to 1 if AltiVec inline assembly is available.])
+    ])
+
+    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
+
+    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"
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM([[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"
+        AC_COMPILE_IFELSE([
+          AC_LANG_PROGRAM([[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"
+          AC_COMPILE_IFELSE([
+            AC_LANG_PROGRAM([[#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"
+            AC_COMPILE_IFELSE([
+              AC_LANG_PROGRAM([[#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"
+              AC_COMPILE_IFELSE([
+                AC_LANG_PROGRAM([[#include <altivec.h>]],
+                                [[vec_ld(0, (unsigned char *)0);]])
+              ],
+              [ac_cv_c_altivec="-fvec"],
+              [ac_cv_c_altivec="no"])
+            ])
+          ])
+        ])
+      ])
+      CFLAGS="${CFLAGS_save}"
+    ])
+
+    AS_IF([test "x${ac_cv_c_altivec}" != "xno"], [
+      CPPFLAGS="${CPPFLAGS_save} ${ac_cv_c_altivec}"
+    ])
+
+    AC_CHECK_HEADERS([altivec.h])
+
+    CPPFLAGS="${CPPFLAGS_save}"
+
+    AS_IF([test "x${ac_cv_c_altivec}" != "xno"], [
+      AC_DEFINE([CAN_COMPILE_C_ALTIVEC], 1,
+                [Define to 1 if C AltiVec extensions are available.])
+      have_altivec="yes"
+    ])
+  ])
+
+  AM_CONDITIONAL([HAVE_ALTIVEC], [test "x${have_altivec}" = "xyes"])
+])
diff --git a/modules/arm_neon/Modules.am b/modules/arm_neon/Modules.am
index 52393b1..ef623c7 100644
--- a/modules/arm_neon/Modules.am
+++ b/modules/arm_neon/Modules.am
@@ -1,5 +1,3 @@
-AM_CFLAGS += $(ARM_NEON_CFLAGS)
-
 libaudio_format_neon_plugin_la_SOURCES = \
 	s32_s16.S \
 	audio_format.c
diff --git a/modules/mmx/Modules.am b/modules/mmx/Modules.am
index b2d4b11..cfbf17d 100644
--- a/modules/mmx/Modules.am
+++ b/modules/mmx/Modules.am
@@ -1,5 +1,3 @@
-AM_CFLAGS += $(MMX_CFLAGS)
-
 libmemcpymmx_plugin_la_SOURCES = memcpy.c fastmemcpy.h
 libmemcpymmx_plugin_la_CFLAGS = $(AM_CFLAGS)
 libmemcpymmx_plugin_la_LIBADD = $(AM_LIBADD)
diff --git a/modules/sse2/Modules.am b/modules/sse2/Modules.am
index 899634b..ac9223f 100644
--- a/modules/sse2/Modules.am
+++ b/modules/sse2/Modules.am
@@ -1,5 +1,3 @@
-AM_CFLAGS += $(SSE2_CFLAGS)
-
 libi420_rgb_sse2_plugin_la_SOURCES = \
         ../video_chroma/i420_rgb.c \
 	../video_chroma/i420_rgb.h \
-- 
1.6.6.1


From dfb728a2ea4d4e9e1e3e3bf433b0f0d6a0a195d8 Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Sat, 30 Jan 2010 22:13:45 +0100
Subject: [PATCH 07/10] Integrate pkg-config handling to vlc_features.m4.


Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac       |   71 +++++++++++++++++++++------------------
 m4/vlc_features.m4 |   71 ++++++++++++++++++++++++++++++++++++++++
 m4/with_pkg.m4     |   92 ----------------------------------------------------
 3 files changed, 109 insertions(+), 125 deletions(-)
 delete mode 100644 m4/with_pkg.m4

diff --git a/configure.ac b/configure.ac
index e3e89a9..692a3fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1259,7 +1259,7 @@ AS_IF([VLC_FEATURE_ENABLED([growl])], [
 dnl
 dnl Libnotify notification plugin
 dnl
-PKG_ENABLE_MODULES_VLC([NOTIFY], [], [libnotify], [libnotify notification], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([notify], [libnotify], [libnotify notification])
 
 dnl
 dnl Audioscrobbler plugin
@@ -1408,8 +1408,8 @@ dnl
 dnl - special access module for dc1394 input
 dnl - dv module: digital video module check for libraw1394
 dnl
-PKG_ENABLE_MODULES_VLC([DC1394], [], [libraw1394 >= 2.0.1 libdc1394-2 >= 2.1.0], [dc1394 access module], [auto])
-PKG_ENABLE_MODULES_VLC([DV], [access_dv], [libraw1394 >= 2.0.1 libavc1394 >= 0.5.3], [DV input module], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([dc1394], [libraw1394 >= 2.0.1 libdc1394-2 >= 2.1.0], [dc1394 access module])
+VLC_PKGCONFIG_FEATURE_MOD([dv], [libraw1394 >= 2.0.1 libavc >= 0.5.3], [DV input module], [access_dv])
 
 dnl
 dnl dvdread module: check for libdvdread
@@ -1781,7 +1781,7 @@ AS_IF([VLC_FEATURE_ENABLED([pvr])], [
 dnl
 dnl  gnomeVFS access module
 dnl
-PKG_ENABLE_MODULES_VLC([GNOMEVFS], [access_gnomevfs], [gnome-vfs-2.0], [GnomeVFS access module], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([gnomevfs], [gnome-vfs-2.0], [GnomeVFS access module], [access_gnomevfs])
 
 dnl
 dnl  VCDX modules
@@ -1916,14 +1916,16 @@ AC_CHECK_FUNCS(inet_ntop,[
 dnl
 dnl  ogg demux plugin
 dnl
-PKG_ENABLE_MODULES_VLC([OGG], [], [ogg >= 1.0], [Ogg demux support], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([ogg], [ogg >= 1.0], [Ogg demux support])
 AS_IF([VLC_FEATURE_ENABLED([sout])], [
-    PKG_ENABLE_MODULES_VLC([MUX_OGG], [], [ogg >= 1.0], [Ogg demux support], [auto])
+  VLC_PKGCONFIG_FEATURE_MOD([mux_ogg], [ogg >= 1.0], [Ogg demux support])
 ])
 
-AS_IF([VLC_FEATURE_ENABLED([sout])], [
+dnl
 dnl Check for libshout
-PKG_ENABLE_MODULES_VLC([SHOUT], [access_output_shout], [shout >= 2.1], [libshout output plugin], [auto])
+dnl
+AS_IF([VLC_FEATURE_ENABLED([sout])], [
+  VLC_PKGCONFIG_FEATURE_MOD([shout], [shout >= 2.1], [libshout output plugin], [access_output_shout])
 ])
 
 dnl
@@ -2367,7 +2369,10 @@ AS_IF([VLC_FEATURE_ENABLED([faad])], [
 dnl
 dnl twolame encoder plugin
 dnl
-PKG_ENABLE_MODULES_VLC([TWOLAME], [], [twolame], [MPEG Audio Layer 2 encoder], [auto], [], [], [ -DLIBTWOLAME_STATIC])
+VLC_PKGCONFIG_FEATURE_MOD([twolame], [twolame], [MPEG Audio Layer 2 encoder])
+AS_IF([test "x${have_twolame}" = "xyes"], [
+  VLC_ADD_CPPFLAGS([twolame], [-DLIBTWOLAME_STATIC])
+])
 
 dnl
 dnl  QuickTime plugin
@@ -2487,22 +2492,22 @@ AS_IF([VLC_FEATURE_ENABLED([a52-fixed])], [
 dnl
 dnl DTS Coherent Acoustics decoder plugin
 dnl
-PKG_ENABLE_MODULES_VLC([DCA], [dtstofloat32], [libdca >= 0.0.5], [DTS Coherent Acoustics support with libdca], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([dca], [libdca >= 0.0.5], [DTS Coherent Acoustics support with libdca], [dtstofloat32])
 
 dnl
 dnl  Flac plugin
 dnl
-PKG_ENABLE_MODULES_VLC([FLAC], [], [flac], [libflac decoder/encoder support], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([flac], [flac], [libflac decoder/encoder support])
 
 dnl
 dnl  Libmpeg2 plugin
 dnl
-PKG_ENABLE_MODULES_VLC([LIBMPEG2], [], [libmpeg2 > 0.3.2], [libmpeg2 decoder support], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([libmpeg2], [libmpeg2 > 0.3.], [libmpeg2 decoder support])
 
 dnl
 dnl  Vorbis plugin
 dnl
-PKG_ENABLE_MODULES_VLC([VORBIS], [], [ogg vorbis >= 1.1 vorbisenc >= 1.1], [Vorbis decoder and encoder], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([vorbis], [ogg vorbis >= 1.1 vorbisenc >= 1.1], [Vorbis decoder and encoder])
 
 dnl
 dnl  Tremor plugin
@@ -2518,22 +2523,22 @@ AS_IF([VLC_FEATURE_ENABLED([tremor])], [
 dnl
 dnl  Speex plugin
 dnl
-PKG_ENABLE_MODULES_VLC([SPEEX], [], [ogg speex >= 1.0.5], [Speex decoder support], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([speex], [ogg speex >= 1.0.5], [Speex decoder support])
 
 dnl
 dnl  theora decoder plugin
 dnl
-PKG_ENABLE_MODULES_VLC([THEORA], [], [ogg theora >= 1.0], [experimental theora codec], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([theora], [ogg theora >= 1.0], [experimental theora codec])
 
 dnl
 dnl  dirac encoder plugin
 dnl
-PKG_ENABLE_MODULES_VLC([DIRAC], [], [dirac >= 0.10.0], [dirac encoder], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([dirac], [dirac >= 0.10.0], [dirac encoder])
 
 dnl
 dnl  schroedinger decoder plugin (for dirac format video)
 dnl
-PKG_ENABLE_MODULES_VLC([SCHROEDINGER], [], [schroedinger-1.0 >= 1.0.6], [dirac decoder using schroedinger], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([schroedinger], [schroedinger-1.0 >= 1.0.6], [dirac decoder using schroedinger])
 
 dnl
 dnl  PNG decoder module
@@ -2616,7 +2621,7 @@ AS_IF([VLC_FEATURE_ENABLED([x264])], [
 dnl
 dnl libfluidsynth (MIDI synthetizer) plugin
 dnl
-PKG_ENABLE_MODULES_VLC([FLUIDSYNTH], [], [fluidsynth], [MIDI synthetiser with libfluidsynth], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([fluidsynth], [fluidsynth], [MIDI synthetiser with libfluidsynth])
 
 dnl
 dnl Teletext Modules
@@ -2937,12 +2942,12 @@ from http://www.freetype.org/, or configure with --disable-freetype. Have a nice
 dnl
 dnl  libxml2 module
 dnl
-PKG_ENABLE_MODULES_VLC([LIBXML2], [xml], [libxml-2.0 >= 2.5], [libxml2 support],[auto])
+VLC_PKGCONFIG_FEATURE_MOD([libxml2], [libxml-2.0 >= 2.5], [libxml2 support], [xml])
 
 dnl
 dnl  SVG module
 dnl
-PKG_ENABLE_MODULES_VLC([SVG], [], [librsvg-2.0 >= 2.9.0], [SVG rendering library],[auto])
+VLC_PKGCONFIG_FEATURE_MOD([svg], [librsvg-2.0 >= 2.9.0], [SVG rendering library])
 
 dnl
 dnl Snapshot vout module (with cache)
@@ -3166,7 +3171,7 @@ AS_IF([VLC_FEATURE_ENABLED([aa])], [
 dnl
 dnl  libcaca plugin
 dnl
-PKG_ENABLE_MODULES_VLC([CACA], [], [caca >= 0.99.beta14], [libcaca output],[auto])
+VLC_PKGCONFIG_FEATURE_MOD([caca], [caca >= 0.99.beta14], [libcaca output])
 
 dnl
 dnl  Audio plugins
@@ -3193,17 +3198,17 @@ AS_IF([VLC_FEATURE_ENABLED([oss])], [
 dnl
 dnl  Pulseaudio module
 dnl
-PKG_ENABLE_MODULES_VLC([PULSE], [], [libpulse >= 0.9.11], [Pulseaudio support], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([pulse], [libpulse >= 0.9.11], [Pulseaudio support])
 
 dnl
 dnl  Portaudio module
 dnl
-PKG_ENABLE_MODULES_VLC([PORTAUDIO], [], [portaudio-2.0], [Portaudio library support], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([portaudio], [portaudio-2.0], [Portaudio library support])
 
 dnl
 dnl  ALSA module
 dnl
-PKG_ENABLE_MODULES_VLC([ALSA], [alsa access_alsa], [alsa >= 1.0.0], [Alsa sound support for linux], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([alsa], [alsa >= 1.0.0], [Alsa sound support for linux], [alsa access_alsa])
 
 dnl
 dnl  win32 waveOut plugin
@@ -3255,7 +3260,7 @@ AS_IF([VLC_FEATURE_ENABLED([hd1000a]) && test "${CXX}" != ""], [
 dnl
 dnl  JACK modules
 dnl
-PKG_ENABLE_MODULES_VLC([JACK], [jack access_jack], [jack], [JACK audio I/O modules],[auto])
+VLC_PKGCONFIG_FEATURE_MOD([jack], [jack], [JACK audio I/O modules], [jack access_jack])
 
 
 dnl
@@ -3334,7 +3339,7 @@ class testclass : public SearchResponseListener, public MediaPlayer
 dnl
 dnl UPnP Plugin (Intel SDK)
 dnl
-PKG_ENABLE_MODULES_VLC([UPNP], [upnp_intel], [libupnp], [Intel UPnp SDK],[auto])
+VLC_PKGCONFIG_FEATURE_MOD([upnp], [libupnp], [Intel UPnp SDK], [upnp_intel])
 
 
 dnl
@@ -3590,12 +3595,12 @@ AS_IF([VLC_FEATURE_ENABLED([visual])], [
 dnl
 dnl  goom visualization plugin
 dnl
-PKG_ENABLE_MODULES_VLC([GOOM], [], [libgoom2], [goom visualization plugin], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([goom], [libgoom2], [goom visualization plugin])
 
 dnl
 dnl libprojectM visualization plugin
 dnl
-PKG_ENABLE_MODULES_VLC([PROJECTM], [], [libprojectM], [projectM visualization plugin], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([projectm], [libprojectM], [projectM visualization plugin])
 
 dnl
 dnl  AtmoLight (homemade Philips Ambilight clone)
@@ -3611,15 +3616,15 @@ AS_IF([VLC_FEATURE_ENABLED([atmo])], [
 
 dnl
 dnl  Bonjour services discovery
-PKG_ENABLE_MODULES_VLC([BONJOUR], [], [avahi-client >= 0.6], [Bonjour services discovery], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([bonjour], [avahi-client >= 0.6], [Bonjour services discovery])
 
 dnl
 dnl  libudev services discovery
-PKG_ENABLE_MODULES_VLC([UDEV], [], [libudev >= 142], [Linux udev services discovery], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([udev], [libudev >= 142], [Linux udev services discovery])
 
 dnl
 dnl MTP devices services discovery
-PKG_ENABLE_MODULES_VLC([MTP], [], [libmtp >= 0.3.0],[MTP devices support],[auto])
+VLC_PKGCONFIG_FEATURE_MOD([mtp], [libmtp >= 0.3.0], [MTP devices support])
 
 dnl
 dnl  Lirc plugin
@@ -3732,7 +3737,7 @@ AS_IF([test "${have_libgcrypt}" = "yes"], [
 dnl
 dnl OSSO (Maemo screen blanking) plugin
 dnl
-PKG_ENABLE_MODULES_VLC([OSSO], [], [libosso], [Maemo support], [auto])
+VLC_PKGCONFIG_FEATURE_MOD([osso], [libosso], [Maemo support])
 
 AS_IF([test -f "/etc/maemo_version"], [
   AC_DEFINE([HAVE_MAEMO], 1, [Define to 1 if building for the Maemo platform.])
@@ -3759,7 +3764,7 @@ dnl
 VLC_FEATURE_OPTION([sqlite], [sqlite support])
 VLC_STRING_OPTION([sqlite], [sqlite path linking], [PATH])
 if test "${SYS}" != "darwin"; then
-  PKG_ENABLE_MODULES_VLC([SQLITE], [], [sqlite3 >= 3.6.0], [sqlite3], [auto])
+  VLC_PKGCONFIG_FEATURE_MOD([sqlite], [sqlite3 >= 3.6.0], [sqlite3])
 else
   AS_IF([VLC_FEATURE_ENABLED([sqlite])], [
     AC_CHECK_HEADERS(sqlite3.h, [
diff --git a/m4/vlc_features.m4 b/m4/vlc_features.m4
index ae11445..cf00100 100644
--- a/m4/vlc_features.m4
+++ b/m4/vlc_features.m4
@@ -1,6 +1,11 @@
 dnl Handling features and arguments to ./configure.
 dnl
 dnl Copyright © 2010 Daniel Mierswa <impulze@impulze.org>
+dnl 
+dnl pkg-config foo is based on previous with_pkg.m4 which is:
+dnl Copyright © 2008 Luca Barbato <lu_zero@gentoo.org>,
+dnl                  Diego Pettenò <flameeyes@gentoo.org>
+dnl                  Jean-Baptiste Kempf
 dnl
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -32,6 +37,11 @@ dnl Create the same string autoconf uses for AC_ARG_ENABLE().
 AC_DEFUN([_VLC_FEATURE_STRING],
   [patsubst([$1], -, _)])
 
+dnl _VLC_PKGCONFIG_PREFIX(ENABLE-STRING)
+dnl Create pkg-config prefix name.
+AC_DEFUN([_VLC_PKGCONFIG_PREFIX],
+  [m4_bpatsubst([m4_toupper([$1])], [- ], _)])
+
 dnl _VLC_FEATURE_CHECK_VARIABLE(ENABLE-STRING, PREFIX, TEST)
 dnl Check if shell variable with prefix_ENABLE-STRING succeeds TEST.
 AC_DEFUN([_VLC_FEATURE_CHECK_VARIABLE], 
@@ -298,3 +308,64 @@ AC_DEFUN([VLC_STRING_OPTION], [
   m4_popdef([var])
   m4_popdef([default_string])
 ])
+
+dnl VLC_PKGCONFIG(ENABLE-STRING, MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl
+dnl Wrap around pkg-config searching for MODULES.
+dnl The pkg-config prefix is the uppercase ENABLE-STRING with '-' and ' ' replaced
+dnl by '_'.
+dnl If pkg-config finds something, have_ENABLE-STRING is set to yes, otherwise no.
+AC_DEFUN([VLC_PKGCONFIG], [
+  AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+  m4_pushdef([prefix], _VLC_PKGCONFIG_PREFIX([$1]))
+
+  probed_modules="$2"
+
+  PKG_CHECK_MODULES(prefix, [$2], [
+    [have_]_VLC_FEATURE_STRING([$1])[="yes"]
+    $3
+  ], [
+    [have_]_VLC_FEATURE_STRING([$1])[="no"]
+    $4
+  ])
+
+  m4_popdef([prefix])
+])
+
+dnl VLC_FEATURE_CHECK(ENABLE-STRING, MESSAGE)
+dnl
+dnl If the package wasn't found but explicitly requested, error out.
+dnl If the package wasn't found but default enabled, warn.
+AC_DEFUN([VLC_FEATURE_CHECK], [
+  AS_IF([_VLC_FEATURE_CHECK_VARIABLE([$1], [have], [!= "xyes"])], [
+    AS_IF([VLC_FEATURE_REQUESTED([$1])], [AC_MSG_ERROR([$2])])
+    AS_IF([VLC_FEATURE_DEFAULT_ENABLED([$1])], [AC_MSG_WARN([$2])])
+  ])
+])
+
+dnl VLC_PKGCONFIG_FEATURE_MOD(ENABLE-STRING, MODULES, DESCRIPTION, [VLC-MODULES],
+dnl                           [DEFAULT-STRING])
+dnl
+dnl Add a VLC feature that is detected by using pkg-config.
+dnl If found add vlc plugins and additional *flags to it.
+dnl Wraps around VLC_FEATURE_OPTION, VLC_PKGCONFIG and VLC_FEATURE_CHECK.
+dnl If VLC-MODULES is blank it defaults to ENABLE-STRING.
+AC_DEFUN([VLC_PKGCONFIG_FEATURE_MOD], [
+  m4_pushdef([prefix], _VLC_PKGCONFIG_PREFIX([$1]))
+  m4_pushdef([module_name], m4_default([$4], [$1]))
+
+  VLC_FEATURE_OPTION([$1], [$3], [$5])
+
+  AS_IF([VLC_FEATURE_ENABLED([$1])], [
+    VLC_PKGCONFIG([$1], [$2], [
+      VLC_ADD_PLUGIN(module_name)
+      VLC_ADD_CFLAGS(module_name, [$]prefix[_CFLAGS])
+      VLC_ADD_LIBS(module_name, [$]prefix[_LIBS])
+    ], [
+      VLC_FEATURE_CHECK([$1], [${probed_modules} not found by pkg-config])
+    ])
+  ])
+
+  m4_popdef([prefix])
+  m4_popdef([module_name])
+])
diff --git a/m4/with_pkg.m4 b/m4/with_pkg.m4
deleted file mode 100644
index 3f6cddc..0000000
--- a/m4/with_pkg.m4
+++ /dev/null
@@ -1,92 +0,0 @@
-dnl with_pkg.m4 - Macros to ease the usage of pkg-config.    -*- Autoconf -*-
-dnl
-dnl Copyright © 2008 Luca Barbato <lu_zero@gentoo.org>,
-dnl                  Diego Pettenò <flameeyes@gentoo.org>
-dnl                  Jean-Baptiste Kempf
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-dnl General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-dnl
-dnl As a special exception to the GNU General Public License, if you
-dnl distribute this file as part of a program that contains a
-dnl configuration script generated by Autoconf, you may include it under
-dnl the same distribution terms that you use for the rest of that program.
-
-dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
-dnl                  [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
-dnl                  [DESCRIPTION], [DEFAULT])
-dnl
-dnl Prepare a --with-variable-prefix triggered check for module,
-dnl disable by default.
-dnl
-
-AC_DEFUN([PKG_WITH_MODULES],
-[
-AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-m4_pushdef([with_arg], m4_tolower([$1]))
-m4_pushdef([description],
-           [m4_default([$5], [build with ]with_arg[ support enabled])])
-
-AC_ARG_ENABLE(with_arg,
-     AS_HELP_STRING([--enable-]with_arg, description[ @<:@default=]auto[@:>@]))
-
-VLC_FEATURE_DEFAULT_ENABLE(with_arg)
-AS_IF([VLC_FEATURE_ENABLED(with_arg)], [
-     PKG_CHECK_MODULES([$1],[$2],[$3],[$4])])
-
-m4_popdef([with_arg])
-m4_popdef([description])
-
-]) dnl PKG_WITH_MODULES
-
-dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
-dnl                       [DESCRIPTION], [DEFAULT])
-dnl
-
-AC_DEFUN([PKG_HAVE_WITH_MODULES],
-[
-PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
-
-AM_CONDITIONAL([HAVE_][$1],
-               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
-])
-
-dnl PKG_ENABLE_MODULES_VLC(VARIABLE-PREFIX,
-dnl                         VLC_MODULE_NAME  dnl (if empty, same as VARIABLE-PREFIX)
-dnl                         PKG MODULES,
-dnl                         [DESCRIPTION], [DEFAULT],
-dnl                         [EXTRA_CFLAGS], [EXTRA_LIBS], [EXTRA_CPPFLAGS]
-AC_DEFUN([PKG_ENABLE_MODULES_VLC],
-[
-m4_pushdef([module_name], AS_TR_SH(m4_default(m4_tolower([$2]),m4_tolower([$1]))))
-m4_pushdef([enable_arg], m4_tolower([$1]))
-
-PKG_WITH_MODULES([$1],[$3],
-    VLC_ADD_PLUGIN(module_name)
-    m4_ifval( m4_normalize([$8]), VLC_ADD_CPPFLAGS(module_name, [$8]))
-    VLC_ADD_CFLAGS(module_name,[$$1_CFLAGS] [$6])
-    VLC_ADD_LIBS(module_name,[$$1_LIBS] [$7])
-    AS_TR_SH([have_]enable_arg)="yes",
-    AS_IF([VLC_FEATURE_REQUESTED(enable_arg)],
-      [AC_MSG_ERROR(Library [$3] needed for [m4_tolower([$1])] was not found)])
-    AS_IF([VLC_FEATURE_DEFAULT_ENABLED(enable_arg)],
-      [AC_MSG_WARN(Library [$3] needed for [m4_tolower([$1])] was not found)])
-    AS_TR_SH([have_]enable_arg)="no",
-    [$4],[$5])
-
-m4_popdef([module_name])
-m4_popdef([enable_arg])
-
-])
-
-- 
1.6.6.1


From f9cd4a50461afb2385acf110352517eb6ab371f4 Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Sat, 30 Jan 2010 23:17:26 +0100
Subject: [PATCH 08/10] Use "the compiler" in configure output instead of $CC.

We could also be using CXX/OBJC compiler. So "the compiler" is more
generic and the user doesn't gain much by seeing his compiler over and
over again anyway.

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 m4/vlc_compiler.m4      |    2 +-
 m4/vlc_optimizations.m4 |   32 ++++++++++++++++----------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/m4/vlc_compiler.m4 b/m4/vlc_compiler.m4
index a3dd07b..040ae4f 100644
--- a/m4/vlc_compiler.m4
+++ b/m4/vlc_compiler.m4
@@ -56,7 +56,7 @@ AC_DEFUN([COMPILEFLAG_CHECK], [
   m4_pushdef([cvar],
              [ac_cv_compflags_]m4_default([$2], m4_tolower(m4_bpatsubst($1, [[- ]], [_]))))
 
-  AC_CACHE_CHECK([if \$CC accepts $1], cvar, [
+  AC_CACHE_CHECK([if the compiler accepts $1], cvar, [
     APPEND_VAR([CFLAGS], [$1])
     APPEND_VAR([CXXFLAGS], [$1])
     APPEND_VAR([OBJCFLAGS], [$1])
diff --git a/m4/vlc_optimizations.m4 b/m4/vlc_optimizations.m4
index 7dc8ff2..ea66548 100644
--- a/m4/vlc_optimizations.m4
+++ b/m4/vlc_optimizations.m4
@@ -9,7 +9,7 @@ AC_DEFUN([VLC_CHECK_MMX], [
   VLC_FEATURE_OPTION([mmx], [enable MMX optimizations], [auto])
 
   AS_IF([VLC_FEATURE_ENABLED([mmx])], [
-    AC_CACHE_CHECK([if $CC groks MMX intrinsics], [ac_cv_c_mmx_intrinsics], [
+    AC_CACHE_CHECK([if the compiler groks MMX intrinsics], [ac_cv_c_mmx_intrinsics], [
       CFLAGS="${CFLAGS_save} -O -mmmx"
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM([[#include <mmintrin.h>
@@ -34,7 +34,7 @@ AC_DEFUN([VLC_CHECK_MMX], [
                 [Define to 1 if MMX intrinsics are available.])
     ])
 
-    AC_CACHE_CHECK([if $CC groks MMX inline assembly], [ac_cv_mmx_inline], [
+    AC_CACHE_CHECK([if the compiler groks MMX inline assembly], [ac_cv_mmx_inline], [
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
                            asm volatile("packuswb %%mm1,%%mm2"::"r"(p));]])
@@ -48,7 +48,7 @@ AC_DEFUN([VLC_CHECK_MMX], [
                 [Define to 1 inline MMX assembly is available.])
     ])
 
-    AC_CACHE_CHECK([if $CC groks MMX EXT inline assembly], [ac_cv_mmxext_inline], [
+    AC_CACHE_CHECK([if the compiler groks MMX EXT inline assembly], [ac_cv_mmxext_inline], [
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
                            asm volatile("maskmovq %%mm1,%%mm2"::"r"(p));]])
@@ -76,7 +76,7 @@ AC_DEFUN([VLC_CHECK_SSE], [
   VLC_FEATURE_OPTION([sse], [enable SSE (1, 2, 3 and 4) optimizations], [auto])
 
   AS_IF([VLC_FEATURE_ENABLED([sse])], [
-    AC_CACHE_CHECK([if $CC groks SSE2 intrinsics], [ac_cv_c_sse2_intrinsics], [
+    AC_CACHE_CHECK([if the compiler groks SSE2 intrinsics], [ac_cv_c_sse2_intrinsics], [
       CFLAGS="${CFLAGS_save} -O -msse2"
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM([[#include <emmintrin.h>
@@ -102,7 +102,7 @@ AC_DEFUN([VLC_CHECK_SSE], [
     ])
 
     # SSE1
-    AC_CACHE_CHECK([if $CC groks SSE inline assembly], [ac_cv_sse_inline], [
+    AC_CACHE_CHECK([if the compiler groks SSE inline assembly], [ac_cv_sse_inline], [
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
                            asm volatile("xorps %%xmm1,%%xmm2"::"r"(p));]])
@@ -116,10 +116,10 @@ AC_DEFUN([VLC_CHECK_SSE], [
                 [Define to 1 if SSE inline assembly is available.])
     ])
 
-    AC_CACHE_CHECK([if $CC groks SSE2 inline assembly], [ac_cv_sse2_inline], [
+    AC_CACHE_CHECK([if the compiler groks SSE2 inline assembly], [ac_cv_sse2_inline], [
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
-                         asm volatile("punpckhqdq %%xmm1,%%xmm2"::"r"(p));]])
+                           asm volatile("punpckhqdq %%xmm1,%%xmm2"::"r"(p));]])
       ],
       [ac_cv_sse2_inline="yes"], [ac_cv_sse2_inline="no"])
     ])
@@ -131,7 +131,7 @@ AC_DEFUN([VLC_CHECK_SSE], [
     ])
 
     # SSE3
-    AC_CACHE_CHECK([if $CC groks SSE3 inline assembly], [ac_cv_sse3_inline], [
+    AC_CACHE_CHECK([if the compiler groks SSE3 inline assembly], [ac_cv_sse3_inline], [
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
                            asm volatile("movsldup %%xmm1,%%xmm0"::"r"(p));]])
@@ -145,7 +145,7 @@ AC_DEFUN([VLC_CHECK_SSE], [
     ])
 
     # SSSE3
-    AC_CACHE_CHECK([if $CC groks SSSE3 inline assembly], [ac_cv_ssse3_inline], [
+    AC_CACHE_CHECK([if the compiler groks SSSE3 inline assembly], [ac_cv_ssse3_inline], [
       CFLAGS="${CFLAGS_save}"
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
@@ -160,7 +160,7 @@ AC_DEFUN([VLC_CHECK_SSE], [
     ])
 
     # SSE4.1
-    AC_CACHE_CHECK([if $CC groks SSE4.1 inline assembly], [ac_cv_sse4_1_inline], [
+    AC_CACHE_CHECK([if the compiler groks SSE4.1 inline assembly], [ac_cv_sse4_1_inline], [
       CFLAGS="${CFLAGS_save}"
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
@@ -175,7 +175,7 @@ AC_DEFUN([VLC_CHECK_SSE], [
     ])
 
     # SSE4.2
-    AC_CACHE_CHECK([if $CC groks SSE4.2 inline assembly], [ac_cv_sse4_2_inline], [
+    AC_CACHE_CHECK([if the compiler groks SSE4.2 inline assembly], [ac_cv_sse4_2_inline], [
       CFLAGS="${CFLAGS_save}"
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
@@ -190,7 +190,7 @@ AC_DEFUN([VLC_CHECK_SSE], [
     ])
 
     # SSE4A
-    AC_CACHE_CHECK([if $CC groks SSE4A inline assembly], [ac_cv_sse4a_inline], [
+    AC_CACHE_CHECK([if the compiler groks SSE4A inline assembly], [ac_cv_sse4a_inline], [
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[void *p;
                            asm volatile("insertq %%xmm1,%%xmm0"::"r"(p));]])
@@ -211,7 +211,7 @@ AC_DEFUN([VLC_CHECK_SSE], [
 
 dnl Check for working 3D Now!
 AC_DEFUN([VLC_CHECK_3DNOW], [
-  AC_CACHE_CHECK([if $CC groks 3D Now! inline assembly], [ac_cv_3dnow_inline], [
+  AC_CACHE_CHECK([if the compiler groks 3D Now! inline assembly], [ac_cv_3dnow_inline], [
     AC_COMPILE_IFELSE([
       AC_LANG_PROGRAM(,[[void *p;
                          asm volatile("pfadd %%mm1,%%mm2"::"r"(p));]])
@@ -235,7 +235,7 @@ AC_DEFUN([VLC_CHECK_NEON], [
   VLC_FEATURE_OPTION([neon], [enable NEON optimizations], [auto])
 
   AS_IF([VLC_FEATURE_ENABLED([neon])], [
-    AC_CACHE_CHECK([if $CC groks NEON inline assembly], [ac_cv_neon_inline], [
+    AC_CACHE_CHECK([if the compiler 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");]])
@@ -259,7 +259,7 @@ AC_DEFUN([VLC_CHECK_ALTIVEC], [
   VLC_FEATURE_OPTION([altivec], [enable AltiVec optimizations], [auto])
 
   AS_IF([VLC_FEATURE_ENABLED([altivec])], [
-    AC_CACHE_CHECK([if $CC groks AltiVec inline assembly], [ac_cv_altivec_inline], [
+    AC_CACHE_CHECK([if the compiler groks AltiVec inline assembly], [ac_cv_altivec_inline], [
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[asm volatile("vperm 0,1,2,3");]])
       ], [ac_cv_altivec_inline="yes"], [
@@ -288,7 +288,7 @@ AC_DEFUN([VLC_CHECK_ALTIVEC], [
     dnl - Linux PPC, gcc 3.x: need <altivec.h> and -fvec
     dnl - Others: test should fail
 
-    AC_CACHE_CHECK([if \$CC groks AltiVec C extensions], [ac_cv_c_altivec], [
+    AC_CACHE_CHECK([if the compiler groks AltiVec C extensions], [ac_cv_c_altivec], [
       # OS X/PPC test (gcc 4.x)
       CFLAGS="${CFLAGS_save} -mpim-altivec -force_cpusubtype_ALL"
       AC_COMPILE_IFELSE([
-- 
1.6.6.1


From 38f512a4354aab403615683053094544d2dc4072 Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Mon, 1 Feb 2010 11:33:59 +0100
Subject: [PATCH 09/10] dvd module was removed in 2004.

See 9eb3e68fa4d4a34b243bf321d93dbf1e33130246

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 692a3fa..60c471a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,7 +158,7 @@ VLC_FEATURE_DEFAULT_DISABLE([peflags])
 AS_CASE(["${SYS}"], 
   [bsdi], [
     APPEND_CFLAGS([-pthread])
-    VLC_ADD_LIBS([dvd dvdcss vcd cdda vcdx],[-ldvd])
+    VLC_ADD_LIBS([dvdcss vcd cdda vcdx],[-ldvd])
   ],
   [bsd], [
     APPEND_CFLAGS([-pthread])
-- 
1.6.6.1


From a32c790e27fde5a10df990149991eefeda401f7f Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Mon, 1 Feb 2010 11:36:28 +0100
Subject: [PATCH 10/10] No longer use LIBS_dvdcss, add dvdcss stuff where needed.


Signed-off-by: Daniel Mierswa <impulze@impulze.org>
---
 configure.ac |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/configure.ac b/configure.ac
index 60c471a..de563f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,7 +158,7 @@ VLC_FEATURE_DEFAULT_DISABLE([peflags])
 AS_CASE(["${SYS}"], 
   [bsdi], [
     APPEND_CFLAGS([-pthread])
-    VLC_ADD_LIBS([dvdcss vcd cdda vcdx],[-ldvd])
+    VLC_ADD_LIBS([vcd cdda vcdx],[-ldvd])
   ],
   [bsd], [
     APPEND_CFLAGS([-pthread])
@@ -1419,20 +1419,20 @@ AS_IF([VLC_FEATURE_ENABLED([dvdread])], [
   VLC_STRING_OPTION([dvdread], [libdvdread headers and libraries], [PATH])
   VLC_STRING_OPTION([dvdread-tree], [libdvdread tree for static linking], [PATH])
 
-  dnl Temporary hack (yeah, sure ;)
-  if test "${SYS}" = "mingw32" || test "${SYS}" = "darwin" || test "${SYS}" = "beos" ; then
-      VLC_ADD_LIBS([dvdread],[-ldvdcss])
-  fi
+  AS_CASE(["${SYS}"],
+    [mingw32|darwin|beos], [VLC_ADD_LIBS([dvdread], [-ldvdcss])],
+    [bsdi], [VLC_ADD_LIBS([dvdread], [-ldvd])]
+  )
 
   AS_IF([VLC_STRING_UNSET([dvdread])], [
     AS_IF([VLC_STRING_UNSET([dvdread-tree])], [
       AC_CHECK_HEADERS(dvdread/dvd_reader.h,
         [ VLC_ADD_PLUGIN([dvdread])
-          VLC_ADD_LIBS([dvdread],[-ldvdread ${LIBS_dvdcss}])
+          VLC_ADD_LIBS([dvdread],[-ldvdread])
         ],[
 	  AC_CHECK_HEADERS(libdvdread/dvd_reader.h,
             [ VLC_ADD_PLUGIN([dvdread])
-	      VLC_ADD_LIBS([dvdread],[-ldvdread ${LIBS_dvdcss}])
+	      VLC_ADD_LIBS([dvdread],[-ldvdread])
 	    ],[
         AS_IF([VLC_FEATURE_REQUESTED([dvdread])], [
 	      AC_MSG_ERROR([cannot find libdvdread headers])
@@ -1453,7 +1453,7 @@ AS_IF([VLC_FEATURE_ENABLED([dvdread])], [
         dnl  Use a custom libdvdread
         AC_MSG_RESULT(${real_dvdread_tree}/dvdread/.libs/libdvdread.a)
         VLC_ADD_PLUGIN([dvdread])
-        VLC_ADD_LIBS([dvdread],[-L${real_dvdread_tree}/dvdread/.libs -ldvdread ${LIBS_dvdcss}])
+        VLC_ADD_LIBS([dvdread],[-L${real_dvdread_tree}/dvdread/.libs -ldvdread])
         VLC_ADD_CPPFLAGS([dvdread],[-I${real_dvdread_tree}])
       else
         dnl  The given libdvdread wasn't built
@@ -1468,7 +1468,7 @@ AS_IF([VLC_FEATURE_ENABLED([dvdread])], [
       dnl  Use ${vlc_string_dvdread}/include/dvdread/dvd_reader.h
       AC_MSG_RESULT(yes)
       VLC_ADD_PLUGIN([dvdread])
-      VLC_ADD_LIBS([dvdread],[-L${vlc_string_dvdread}/lib -ldvdread ${LIBS_dvdcss}])
+      VLC_ADD_LIBS([dvdread],[-L${vlc_string_dvdread}/lib -ldvdread])
       VLC_ADD_CPPFLAGS([dvdread],[-I${vlc_string_dvdread}/include])
     else
       dnl  No libdvdread could be found, sorry
@@ -1483,10 +1483,10 @@ dnl  libdvdnav plugin
 dnl
 VLC_FEATURE_OPTION([dvdnav], [dvdnav input module])
 AS_IF([VLC_FEATURE_ENABLED([dvdnav])], [
-  dnl Same hack than dvdread
-  if test "${SYS}" = "mingw32" || test "${SYS}" = "darwin" || test "${SYS}" = "beos" ; then
-      VLC_ADD_LIBS([dvdnav],[-ldvdcss])
-  fi
+  AS_CASE(["${SYS}"],
+    [mingw32|darwin|beos], [VLC_ADD_LIBS([dvdnav], [-ldvdcss])],
+    [bsdi], [VLC_ADD_LIBS([dvdnav], [-ldvd])]
+  )
 
   DVDNAV_PATH="${PATH}"
   VLC_STRING_OPTION([dvdnav-config-path], [dvdnav-config path], [PATH], [search in \$PATH])
-- 
1.6.6.1

