🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.2 KiB

  1. # PKG_PROG_PKG_CONFIG([MIN-VERSION])
  2. # ----------------------------------
  3. AC_DEFUN([PKG_PROG_PKG_CONFIG],
  4. [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
  5. m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
  6. AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
  7. AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
  8. AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
  9. if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
  10. AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
  11. fi
  12. if test -n "$PKG_CONFIG"; then
  13. _pkg_min_version=m4_default([$1], [0.9.0])
  14. AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
  15. if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
  16. AC_MSG_RESULT([yes])
  17. else
  18. AC_MSG_RESULT([no])
  19. PKG_CONFIG=""
  20. fi
  21. fi[]dnl
  22. ])# PKG_PROG_PKG_CONFIG
  23. # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  24. #
  25. # Check to see whether a particular set of modules exists. Similar
  26. # to PKG_CHECK_MODULES(), but does not set variables or print errors.
  27. #
  28. # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  29. # only at the first occurence in configure.ac, so if the first place
  30. # it's called might be skipped (such as if it is within an "if", you
  31. # have to call PKG_CHECK_EXISTS manually
  32. # --------------------------------------------------------------
  33. AC_DEFUN([PKG_CHECK_EXISTS],
  34. [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
  35. if test -n "$PKG_CONFIG" && \
  36. AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
  37. m4_default([$2], [:])
  38. m4_ifvaln([$3], [else
  39. $3])dnl
  40. fi])
  41. # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
  42. # ---------------------------------------------
  43. m4_define([_PKG_CONFIG],
  44. [if test -n "$$1"; then
  45. pkg_cv_[]$1="$$1"
  46. elif test -n "$PKG_CONFIG"; then
  47. PKG_CHECK_EXISTS([$3],
  48. [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
  49. [pkg_failed=yes])
  50. else
  51. pkg_failed=untried
  52. fi[]dnl
  53. ])# _PKG_CONFIG
  54. # _PKG_SHORT_ERRORS_SUPPORTED
  55. # -----------------------------
  56. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
  57. [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  58. if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
  59. _pkg_short_errors_supported=yes
  60. else
  61. _pkg_short_errors_supported=no
  62. fi[]dnl
  63. ])# _PKG_SHORT_ERRORS_SUPPORTED
  64. # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
  65. # [ACTION-IF-NOT-FOUND])
  66. #
  67. #
  68. # Note that if there is a possibility the first call to
  69. # PKG_CHECK_MODULES might not happen, you should be sure to include an
  70. # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
  71. #
  72. #
  73. # --------------------------------------------------------------
  74. AC_DEFUN([PKG_CHECK_MODULES],
  75. [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
  76. AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
  77. AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
  78. pkg_failed=no
  79. AC_MSG_CHECKING([for $1])
  80. _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
  81. _PKG_CONFIG([$1][_LIBS], [libs], [$2])
  82. m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
  83. and $1[]_LIBS to avoid the need to call pkg-config.
  84. See the pkg-config man page for more details.])
  85. if test $pkg_failed = yes; then
  86. AC_MSG_RESULT([no])
  87. _PKG_SHORT_ERRORS_SUPPORTED
  88. if test $_pkg_short_errors_supported = yes; then
  89. $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
  90. else
  91. $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
  92. fi
  93. # Put the nasty error message in config.log where it belongs
  94. echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
  95. m4_default([$4], [AC_MSG_ERROR(
  96. [Package requirements ($2) were not met:
  97. $$1_PKG_ERRORS
  98. Consider adjusting the PKG_CONFIG_PATH environment variable if you
  99. installed software in a non-standard prefix.
  100. _PKG_TEXT])dnl
  101. ])
  102. elif test $pkg_failed = untried; then
  103. AC_MSG_RESULT([no])
  104. m4_default([$4], [AC_MSG_FAILURE(
  105. [The pkg-config script could not be found or is too old. Make sure it
  106. is in your PATH or set the PKG_CONFIG environment variable to the full
  107. path to pkg-config.
  108. _PKG_TEXT
  109. To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl
  110. ])
  111. else
  112. $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
  113. $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
  114. AC_MSG_RESULT([yes])
  115. $3
  116. fi[]dnl
  117. ])# PKG_CHECK_MODULES