2
0

extra_pkg.m4 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # extra_pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
  2. #
  3. # Copyright (c) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
  4. # Copyright (c) 2004 Scott James Remnant <scott@netsplit.com>.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. # General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. #
  20. # As a special exception to the GNU General Public License, if you
  21. # distribute this file as part of a program that contains a
  22. # configuration script generated by Autoconf, you may include it under
  23. # the same distribution terms that you use for the rest of that program.
  24. # --------------------------------------------------------------
  25. # PKG_CHECK_MOD_VERSION(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
  26. # [ACTION-IF-NOT-FOUND])
  27. #
  28. # This is a very slight modification to the macro PKG_CHECK_MODULES that
  29. # is in the original pkg.m4 file. It prints the versions in the checking
  30. # message (erikd@mega-nerd.com).
  31. AC_DEFUN([PKG_CHECK_MOD_VERSION],
  32. [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
  33. AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
  34. AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
  35. pkg_failed=no
  36. AC_MSG_CHECKING([for $2 ])
  37. _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
  38. _PKG_CONFIG([$1][_LIBS], [libs], [$2])
  39. pkg_link_saved_CFLAGS=$CFLAGS
  40. pkg_link_saved_LIBS=$LIBS
  41. eval "pkg_CFLAGS=\${pkg_cv_[]$1[]_CFLAGS}"
  42. eval "pkg_LIBS=\${pkg_cv_[]$1[]_LIBS}"
  43. CFLAGS="$CFLAGS $pkg_CFLAGS"
  44. LIBS="$LIBS $pkg_LIBS"
  45. AC_TRY_LINK([], puts ("");, pkg_link=yes, pkg_link=no)
  46. CFLAGS=$pkg_link_saved_CFLAGS
  47. LIBS=$pkg_link_saved_LIBS
  48. if test $pkg_link = no ; then
  49. $as_echo_n "link failed ... "
  50. pkg_failed=yes
  51. fi
  52. m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
  53. and $1[]_LIBS to avoid the need to call pkg-config.
  54. See the pkg-config man page for more details.])
  55. if test $pkg_failed = yes; then
  56. _PKG_SHORT_ERRORS_SUPPORTED
  57. if test $_pkg_short_errors_supported = yes; then
  58. $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
  59. else
  60. $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
  61. fi
  62. # Put the nasty error message in config.log where it belongs
  63. echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
  64. ifelse([$4], , [AC_MSG_ERROR(dnl
  65. [Package requirements ($2) were not met:
  66. $$1_PKG_ERRORS
  67. Consider adjusting the PKG_CONFIG_PATH environment variable if you
  68. installed software in a non-standard prefix.
  69. _PKG_TEXT
  70. ])],
  71. [AC_MSG_RESULT([no])
  72. $4])
  73. elif test $pkg_failed = untried; then
  74. ifelse([$4], , [AC_MSG_FAILURE(dnl
  75. [The pkg-config script could not be found or is too old. Make sure it
  76. is in your PATH or set the PKG_CONFIG environment variable to the full
  77. path to pkg-config.
  78. _PKG_TEXT
  79. To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
  80. [$4])
  81. else
  82. $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
  83. $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
  84. AC_MSG_RESULT([yes])
  85. ifelse([$3], , :, [$3])
  86. fi[]dnl
  87. ])# PKG_CHECK_MOD_VERSION