1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# This file is part of UltraStar Deluxe
# Created by the UltraStar Deluxe Team
# OVERVIEW
#
# PKG_VALUE(VARIABLE_PREFIX, POSTFIX, COMMAND, MODULE, HELP-STRING)
# PKG_VERSION(VARIABLE_PREFIX, MODULE)
# PKG_HAVE(VARIABLE_PREFIX, MODULE, [REQUIRED])
# AX_TRIM(STRING)
# SYNOPSIS
#
# PKG_VALUE(VARIABLE_PREFIX, POSTFIX, COMMAND, MODULE, HELP-STRING)
#
# DESCRIPTION
#
# Calls pkg-config with a given command and stores the result.
# If the variable was already defined by the user or the package
# is not present on the system ([$VARIABLE_PREFIX]_HAVE <> yes)
# pkg-config will not be executed and the old value remains.
# In addition the variable will be shown on "./configure --help"
# described by a given help-string.
#
# Parameters:
# - VARIABLE_PREFIX: the prefix for the variables storing
# information about the package.
# - POSTFIX: [$VARIABLE_PREFIX]_[$POSTFIX] will contain the value
# - COMMAND: a pkg-config command, e.g. "variable=prefix"
# - MODULE: the package pkg-config will retrieve info from
# - HELP-STRING: description of the variable
#
# Sets:
# [$VARIABLE_PREFIX]_[$POSTFIX] # value (AC_SUBST)
AC_DEFUN([PKG_VALUE],
[
AC_ARG_VAR([$1]_[$2], [$5, overriding pkg-config])
# check if variable was defined by the user
if test -z "$[$1]_[$2]"; then
# if not, get it from pkg-config
if test x$[$1][_HAVE] = xyes; then
PKG_CHECK_EXISTS([$4],
[[$1]_[$2]=`$PKG_CONFIG --[$3] --silence-errors "$4"`],
[# print error message and quit
err_msg=`$PKG_CONFIG --errors-to-stdout --print-errors "$4"`
AC_MSG_ERROR(
[
$err_msg
If --with-[$1]=nocheck is defined the environment variable
[$1]_[$2]
must be set to avoid the need to call pkg-config.
See the pkg-config man page for more details.
])
])
fi
fi
AC_SUBST([$1]_[$2])
])
# SYNOPSIS
#
# PKG_VERSION(VARIABLE_PREFIX, MODULE)
#
# DESCRIPTION
#
# Retrieves the version of a package
#
# Parameters:
# - VARIABLE_PREFIX: the prefix for the variables storing
# information about the package.
# - MODULE: package name according to pkg-config
#
# Sets:
# [$VARIABLE_PREFIX]_VERSION # full version string
# # (format: "major.minor.release")
#
# [$VARIABLE_PREFIX]_VERSION_MAJOR # major version number
# [$VARIABLE_PREFIX]_VERSION_MINOR # minor version number
# [$VARIABLE_PREFIX]_VERSION_RELEASE # release version number
#
# [$VARIABLE_PREFIX]_VERSION_INT # integer representation:
# # MMMmmmrrr (M:major,m:minor,r:release)
AC_DEFUN([PKG_VERSION],
[
if test x$[$1][_HAVE] = xyes; then
AC_MSG_CHECKING([version of $1])
PKG_VALUE([$1], [VERSION], [modversion], [$2], [version of $1])
AC_MSG_RESULT(@<:@$[$1][_VERSION]@:>@)
else
[$1][_VERSION]="0.0.0"
fi
AX_EXTRACT_VERSION([$1], $[$1][_VERSION])
])
# SYNOPSIS
#
# AX_TRIM(STRING)
#
# DESCRIPTION
#
# Removes surrounding whitespace
AC_DEFUN([AX_TRIM],
[
echo "[$1]" | $SED 's/^[[ \t]]*//' | $SED 's/[[ \t]]*$//'
])
# SYNOPSIS
#
# PKG_HAVE(VARIABLE_PREFIX, MODULE, [REQUIRED])
#
# DESCRIPTION
#
# Checks with pkg-config if a package exists and retrieves
# information about it.
#
# Parameters:
# - VARIABLE_PREFIX: the prefix for the variables storing information about the package.
# - MODULE: package name according to pkg-config
# - REQUIRED: if true, the configure-script is aborted if the package was not found
#
# Uses:
# with_[$VARIABLE_PREFIX]: whether and how the package should be checked for
# "check": check for the package but do not abort if it does not exist (default)
# "no": do not check for the package (sets _HAVE to "no" and _VERSION to "0.0.0")
# "yes": check for the package and abort if it does not exist
# "nocheck": do not check for the package (sets _HAVE to "yes")
#
# Sets:
# [$VARIABLE_PREFIX]_HAVE # package is available (values: "yes"|"no")
# [$VARIABLE_PREFIX]_LIBS # linker flags (e.g. -Lmylibdir -lmylib)
# [$VARIABLE_PREFIX]_LIBDIRS # library dirs (e.g. -Lmylibdir)
AC_DEFUN([PKG_HAVE],
[
have_lib="no"
AC_MSG_CHECKING([for $2])
if test x"$with_[$1]" = xnocheck; then
# do not call pkg-config, use user settings
have_lib="yes"
elif test x"$with_[$1]" != xno; then
# check if package exists
PKG_CHECK_EXISTS([$2], [
have_lib="yes"
[$1][_LIBS]=`$PKG_CONFIG --libs --silence-errors "$2"`
[$1][_LIBDIRS]=`$PKG_CONFIG --libs-only-L --silence-errors "$2"`
[$1][_LIBDIRS]=`AX_TRIM($[$1][_LIBDIRS])`
# add library directories to LIBS (ignore *_LIBS for now)
if test -n "$[$1][_LIBDIRS]"; then
LIBS="$LIBS $[$1][_LIBDIRS]"
fi
])
fi
if test x$have_lib = xyes; then
[$1][_HAVE]="yes"
if test -n "$[$1][_LIBDIRS]"; then
# show additional lib-dirs
AC_MSG_RESULT(yes [(]$[$1][_LIBDIRS][)])
else
AC_MSG_RESULT(yes)
fi
else
[$1][_HAVE]="no"
AC_MSG_RESULT(no)
# check if package is required
if test x$3 = xyes -o x"$with_[$1]" = xyes ; then
# print error message and quit
err_msg=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
AC_MSG_ERROR(
[
$err_msg
Alternatively, you may set --with-[$1]=nocheck and the environment
variables [$1]_[[...]] (see configure --help)
to appropriate values to avoid the need to call pkg-config.
See the pkg-config man page for more details.
])
fi
fi
])
|