]> git.draconx.ca Git - aspectbin.git/blob - m4/pkgvar.m4
Avoid use of test -z in PKG_CHECK_VAR.
[aspectbin.git] / m4 / pkgvar.m4
1 dnl PKG_CHECK_VAR(prefix, var, desc, pkg, [action-if-ok], [action-if-fail])
2 AC_DEFUN([PKG_CHECK_VAR],
3 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
4 AC_ARG_VAR(m4_toupper([$1][_$2]), [$3, overriding pkg-config])dnl
5
6 m4_define([_PKG_VAR_TEXT], [dnl
7 Alternately, you may set the environment variable m4_toupper([$1][_$2]) to
8 avoid the need to call pkg-config.
9 See the pkg-config man page for more details.])
10
11 pkg_fail=no
12 AC_MSG_CHECKING([for $3])
13 if test x"$[]m4_toupper([$1][_$2])" = x; then
14         _PKG_CONFIG([$1][_$2], [variable=$2], [$4])
15 else
16         pkg_cv_$1[]_$2="$[]m4_toupper([$1][_$2])"
17 fi
18
19 if test x"[$pkg_cv_$1][_$2]" = x; then
20         if test $pkg_failed = yes; then
21                 _PKG_SHORT_ERRORS_SUPPORTED
22                 if test $_pkg_short_errors_supported = yes; then
23                         $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$4" 2>&1`
24                 else
25                         $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$4" 2>&1`
26                 fi
27                 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
28
29                 ifelse([$6], ,
30                         [AC_MSG_ERROR([dnl
31 Package requirements ($4) were not met:
32
33 $$1_PKG_ERRORS
34
35 Consider adjusting the PKG_CONFIG_PATH environment variable if you installed
36 software in a non-standard prefix.
37
38 _PKG_VAR_TEXT
39 ])],
40                         [AC_MSG_RESULT([unknown])
41                         $6])
42         elif test $pkg_failed = untried; then
43                 ifelse([$6], ,
44                         [AC_MSG_FAILURE([dnl
45 The pkg-config script could not be found or is too old.  Make sure it is in
46 your PATH or set the PKG_CONFIG environment variable to the full path to
47 pkg-config.
48
49 _PKG_VAR_TEXT
50
51 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
52                         [$6])
53         else
54                 ifelse([$6], ,
55                         [AC_MSG_ERROR([dnl
56 The variable ``$2'' was not defined in the package description database for dnl
57 m4_apply([m4_car], m4_split([$4])).
58
59 Consider adjusting the PKG_CONFIG_PATH environment variable if you installed
60 software in a non-standard prefix.
61
62 _PKG_VAR_TEXT
63 ])],
64                         [AC_MSG_RESULT([unknown])
65                         $6])
66         fi
67 else
68         $1[]_$2=$pkg_cv_$1[]_$2
69         AC_MSG_RESULT([$$1][_$2])
70         ifelse([$5], , :, [$5])
71 fi
72 ])