[vlc-devel] commit: Configure, create a m4cro for checking dependencies in pkg_config ( Jean-Baptiste Kempf )

git version control git at videolan.org
Wed Aug 5 18:38:18 CEST 2009


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Aug  5 16:56:34 2009 +0200| [251ca87c73952a9731b3822b0e73ead755dd4777] | committer: Jean-Baptiste Kempf 

Configure, create a m4cro for checking dependencies in pkg_config

--enable-foo will search for the foo.pc and die if not provided
--disable-foo will not search anything related to foo
'' will search for foo.pc and give a message if foo.pc is not provided.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=251ca87c73952a9731b3822b0e73ead755dd4777
---

 configure.ac   |   83 +++--------------------------------------------
 m4/with_pkg.m4 |   98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+), 78 deletions(-)

diff --git a/configure.ac b/configure.ac
index bc84d52..ac2b9b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3501,47 +3501,7 @@ fi
 dnl
 dnl  Speex plugin
 dnl
-AC_ARG_ENABLE(speex,
-  [  --enable-speex          Speex decoder support (default enabled)])
-if test "${enable_speex}" != "no"
-then
-  AC_ARG_WITH(speex-tree,
-  [    --with-speex-tree=PATH speex tree for static linking])
-  if test -n "${with_speex_tree}"
-  then
-    AC_MSG_CHECKING(for libspeex.a in ${with_speex_tree})
-    real_speex_tree="`cd ${with_speex_tree} 2>/dev/null && pwd`"
-    if test -z "${real_speex_tree}"
-    then
-      dnl  The given directory can't be found
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot cd to ${with_speex_tree}])
-    fi
-    if test -f "${real_speex_tree}/libspeex/.libs/libspeex.a"
-    then
-      dnl  Use a custom speex
-      AC_MSG_RESULT(${real_speex_tree}/libspeex/.libs/libspeex.a)
-      VLC_ADD_PLUGIN([speex])
-      VLC_ADD_LIBS([speex],[${real_speex_tree}/libspeex/.libs/libspeex.a])
-      VLC_ADD_CFLAGS([speex],[-I${real_speex_tree}/include])
-    else
-      dnl  The given speex wasn't built
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot find ${real_speex_tree}/libspeex/.libs/libspeex.a, make sure you compiled speex in ${with_speex_tree}])
-    fi
-  else
-    AC_CHECK_HEADERS(speex/speex.h, [
-      LDFLAGS="${LDFLAGS_save} ${LIBS_speex}"
-      AC_CHECK_LIB(speex, speex_decode_int, [
-        VLC_ADD_PLUGIN([speex])
-        VLC_ADD_LIBS([speex],[-lspeex]) ],
-        [ AC_MSG_RESULT([no])
-          AC_MSG_WARN([Your libspeex is too old, please get the development
-                       version.]) ],[])
-      LDFLAGS="${LDFLAGS_save}"
-      ],[])
-  fi
-fi
+PKG_ENABLE_MODULES_VLC([SPEEX], [speex >= 1.0.5], [Speex decoder support], [auto])
 
 dnl
 dnl  tarkin decoder plugin
@@ -3574,50 +3534,17 @@ fi
 dnl
 dnl  theora decoder plugin
 dnl
-AC_ARG_ENABLE(theora,
-[  --enable-theora         experimental theora codec (default disabled)])
-if test "${enable_theora}" = "yes"
-then
-  AC_CHECK_HEADERS(theora/theora.h, [
-    AC_CHECK_LIB(theora, theora_granule_time, [
-      VLC_ADD_PLUGIN([theora])
-      theora_libs="-ltheora -logg"
-      VLC_ADD_LIBS([theora],[${theora_libs}]) ],[
-      AC_MSG_ERROR([libtheora doesn't appear to be installed on your system.
-You also need to check that you have a libogg posterior to the 1.0 release.])],
-      [-logg])
-  ])
-fi
+PKG_ENABLE_MODULES_VLC([THEORA], [theora >= 1.0], [experimental theora codec], [auto])
 
 dnl
-dnl  dirac decoder plugin
+dnl  dirac encoder plugin
 dnl
-AC_ARG_ENABLE(dirac,
-[  --enable-dirac          experimental dirac codec (default disabled)])
-if test "${enable_dirac}" = "yes"; then
-  PKG_CHECK_MODULES(DIRAC,[dirac >= 0.10.0], [
-      VLC_ADD_PLUGIN([dirac])
-      VLC_ADD_CFLAGS([dirac],[$DIRAC_CFLAGS])
-      VLC_ADD_LIBS([dirac],[$DIRAC_LIBS -lstdc++]) ],[
-      AC_MSG_ERROR([libdirac >= 0.10.0 doesn't appear to be installed on your system.])
-  ])
-fi
+PKG_ENABLE_MODULES_VLC([DIRAC], [dirac >= 0.10.0], [dirac encoder], [auto], [], [ -lstdc++])
 
 dnl
 dnl  schroedinger decoder plugin (for dirac format video)
 dnl
-AC_ARG_ENABLE(schroedinger,
-[  --disable-schroedinger  high performance dirac codec (default enabled)])
-if test "${enable_schroedinger}" != "no"; then
-  PKG_CHECK_MODULES(SCHROEDINGER,[schroedinger-1.0 >= 1.0.6], [
-      VLC_ADD_PLUGIN([schroedinger])
-      VLC_ADD_CFLAGS([schroedinger],[$SCHROEDINGER_CFLAGS])
-      VLC_ADD_LIBS([schroedinger],[$SCHROEDINGER_LIBS]) ], [
-        AS_IF([test "x${enable_schroedinger}" != "x"], [
-          AC_MSG_ERROR([${SCHROEDINGER_PKG_ERRORS}])
-        ])
-])
-fi
+PKG_ENABLE_MODULES_VLC([SCHROEDINGER], [schroedinger-1.0 >= 1.0.6], [dirac decoder using schroedinger], [auto])
 
 dnl
 dnl  PNG decoder module
diff --git a/m4/with_pkg.m4 b/m4/with_pkg.m4
new file mode 100644
index 0000000..23a7525
--- /dev/null
+++ b/m4/with_pkg.m4
@@ -0,0 +1,98 @@
+dnl with_pkg.m4 - Macros to ease the usage of pkg-config.    -*- Autoconf -*-
+dnl
+dnl Copyright © 2008 Luca Barbato <lu_zero at gentoo.org>,
+dnl                  Diego Pettenò <flameeyes at 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])])
+
+m4_pushdef([def_arg], [m4_default([$6], [auto])])
+m4_pushdef([def_action_if_found], [AS_TR_SH([enable_]with_arg)=yes])
+m4_pushdef([def_action_if_not_found], [AS_TR_SH([enable_]with_arg)=no])
+
+m4_case(def_arg,
+            [yes],[m4_pushdef([with_without], [--disable-]with_arg)],
+            [m4_pushdef([with_without],[--enable-]with_arg)])
+
+AC_ARG_ENABLE(with_arg,
+     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
+    [AS_TR_SH([enable_]with_arg)=def_arg])
+
+AS_CASE([$AS_TR_SH([enable_]with_arg)],
+            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
+            [auto],[PKG_CHECK_MODULES([$1],[$2],
+                                        [m4_n([def_action_if_found]) $3],
+                                        [m4_n([def_action_if_not_found]) $4])])
+
+m4_popdef([with_arg])
+m4_popdef([description])
+m4_popdef([def_arg])
+
+]) 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, MODULES,
+dnl                         [DESCRIPTION], [DEFAULT],
+dnl                         [EXTRA_CFLAGS], [EXTRA_LIBS])
+AC_DEFUN([PKG_ENABLE_MODULES_VLC],
+[
+PKG_WITH_MODULES([$1],[$2],
+    VLC_ADD_PLUGIN(m4_tolower([$1]))
+    VLC_ADD_CFLAGS(m4_tolower([$1]),[$$1_CFLAGS] [$5] )
+    VLC_ADD_LIBS(m4_tolower([$1]),[$$1_LIBS] [$6]),
+    AS_IF([test x"$AS_TR_SH([enable_]m4_tolower([$1]))" = "xyes"],
+        [AC_MSG_ERROR(Library [$2] needed for [m4_tolower([$1]) was not found])],
+        [AC_MSG_WARN(Library [$2] needed for [m4_tolower([$1]) was not found])]
+         ),
+    [$3],[$4])
+
+
+AM_CONDITIONAL([HAVE_][$1],
+               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
+
+])
+




More information about the vlc-devel mailing list