1 # Copyright © 2014, 2024 Nick Bowler
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 # DX_PKG_CONFIG(shell-variable, arguments,
17 # [action-if-ok], [action-if-failed],
18 # [action-if-not-available])
20 # Execute pkg-config with the given arguments, and store the output in
21 # the specified shell variable. If successful, execute action-if-ok. If
22 # unsuccessful, execute action-if-failed. If pkg-config is not available,
23 # execute action-if-not-available.
24 AC_DEFUN([DX_PKG_CONFIG], [AC_REQUIRE([DX_PROG_PKG_CONFIG])dnl
26 AS_IF([test ${PKG_CONFIG:+y}],
27 [DX_COMMAND_OUTPUT([$1], [$PKG_CONFIG --print-errors $2],
28 [$3], [m4_default([$4], [AS_SET_STATUS([$?])])])],
29 [m4_default([$5], [AS_SET_STATUS([2])])])])
32 AC_DEFUN_ONCE([DX_PROG_PKG_CONFIG],
33 [AC_ARG_VAR([PKG_CONFIG],
34 [Command to help determine library build flags])dnl
35 AC_ARG_VAR([PKG_CONFIG_PATH],
36 [Additional pkg-config database directories to search])dnl
37 AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])])