| 1 |
dnl # Check for working installations of TagLib and its C-wrapper library, |
| 2 |
dnl # libtag_c. |
| 3 |
dnl # Provides appropriate --with configuration options, fills the |
| 4 |
dnl # TAGLIB_CFLAGS, TAGLIB_CPPFLAGS, TAGLIB_LDFLAGS, TAGLIB_LIBS and |
| 5 |
dnl # TAGLIB_C_LIBS variables accordingly. |
| 6 |
|
| 7 |
|
| 8 |
dnl # Copyright (c) 2008, 2009 Moritz Grimm <[email protected]> |
| 9 |
dnl # |
| 10 |
dnl # Permission to use, copy, modify, and distribute this software for any |
| 11 |
dnl # purpose with or without fee is hereby granted, provided that the above |
| 12 |
dnl # copyright notice and this permission notice appear in all copies. |
| 13 |
dnl # |
| 14 |
dnl # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 15 |
dnl # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 16 |
dnl # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 17 |
dnl # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 18 |
dnl # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 19 |
dnl # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 20 |
dnl # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 21 |
|
| 22 |
|
| 23 |
dnl # Both check functions provide TAGLIB_CPPFLAGS and TAGLIB_LDFLAGS. |
| 24 |
|
| 25 |
dnl # For TAGLIB_LIBS: |
| 26 |
dnl # AX_CHECK_TAGLIB([TAGLIB-VERSION], [ACTION-IF-FOUND], |
| 27 |
dnl # [ACTION-IF-NOT-FOUND]) |
| 28 |
|
| 29 |
dnl # For TAGLIB_C_LIBS: |
| 30 |
dnl # AX_CHECK_TAGLIB_C([TAGLIB-VERSION], [ACTION-IF-FOUND], |
| 31 |
dnl # [ACTION-IF-NOT-FOUND]) |
| 32 |
|
| 33 |
|
| 34 |
AC_DEFUN([_AX_CHECK_TAGLIB_OPTS], |
| 35 |
[ |
| 36 |
AC_REQUIRE([PKG_PROG_PKG_CONFIG]) |
| 37 |
if test -z "${PKG_CONFIG}"; then |
| 38 |
AC_MSG_ERROR([The pkg-config utility is required.], [1]) |
| 39 |
fi |
| 40 |
AC_ARG_VAR([TAGLIB_CFLAGS], |
| 41 |
[C compiler flags for TagLib]) |
| 42 |
AC_ARG_VAR([TAGLIB_CPPFLAGS], |
| 43 |
[C preprocessor flags for TagLib]) |
| 44 |
AC_ARG_VAR([TAGLIB_LDFLAGS], |
| 45 |
[linker flags for TagLib]) |
| 46 |
have_taglib_includes="" |
| 47 |
have_taglib_libs="" |
| 48 |
want_taglib="auto" |
| 49 |
AC_ARG_WITH([taglib], |
| 50 |
[AS_HELP_STRING([--with-taglib=PFX], |
| 51 |
[prefix where the TagLib header files and library are installed (default: autodetect)])], |
| 52 |
[ |
| 53 |
case "${withval}" in |
| 54 |
yes) |
| 55 |
want_taglib="yes" |
| 56 |
;; |
| 57 |
no) |
| 58 |
want_taglib="no" |
| 59 |
;; |
| 60 |
*) |
| 61 |
have_taglib_prefix="${withval}" |
| 62 |
want_taglib="yes" |
| 63 |
;; |
| 64 |
esac |
| 65 |
] |
| 66 |
) |
| 67 |
AC_ARG_WITH([taglib-includes], |
| 68 |
[AS_HELP_STRING([--with-taglib-includes=DIR], |
| 69 |
[directory where TagLib header files are installed (optional)]) ], |
| 70 |
[ |
| 71 |
case "${withval}" in |
| 72 |
yes|no) ;; |
| 73 |
*) |
| 74 |
have_taglib_includes="${withval}" |
| 75 |
;; |
| 76 |
esac |
| 77 |
] |
| 78 |
) |
| 79 |
AC_ARG_WITH([taglib-libs], |
| 80 |
[AS_HELP_STRING([--with-taglib-libs=DIR], |
| 81 |
[directory where TagLib is installed (optional)]) ], |
| 82 |
[ |
| 83 |
case "${withval}" in |
| 84 |
yes|no) ;; |
| 85 |
*) |
| 86 |
have_taglib_libs="${withval}" |
| 87 |
;; |
| 88 |
esac |
| 89 |
] |
| 90 |
) |
| 91 |
AC_CACHE_VAL([local_cv_have_lib_taglib_opts], |
| 92 |
[ |
| 93 |
ax_check_taglib_taglib_pc="no" |
| 94 |
PKG_CHECK_EXISTS([taglib], [ax_check_taglib_taglib_pc=yes]) |
| 95 |
if test -z "${TAGLIB_CFLAGS}" \ |
| 96 |
-a x"${ax_check_taglib_taglib_pc}" = "xyes"; then |
| 97 |
TAGLIB_CFLAGS="`${PKG_CONFIG} --cflags-only-other taglib`" |
| 98 |
fi |
| 99 |
if test -n "${TAGLIB_CPPFLAGS}"; then |
| 100 |
if test -n "${have_taglib_includes}"; then |
| 101 |
TAGLIB_CPPFLAGS="${TAGLIB_CPPFLAGS} -I${have_taglib_includes}" |
| 102 |
fi |
| 103 |
else |
| 104 |
if test -n "${have_taglib_includes}"; then |
| 105 |
TAGLIB_CPPFLAGS="-I${have_taglib_includes}" |
| 106 |
else |
| 107 |
if test x"${want_taglib}" = "xauto" \ |
| 108 |
-a x"${ax_check_taglib_taglib_pc}" = "xyes"; then |
| 109 |
TAGLIB_CPPFLAGS="`${PKG_CONFIG} --cflags-only-I taglib`" |
| 110 |
elif test -n "${have_taglib_prefix}"; then |
| 111 |
TAGLIB_CPPFLAGS="-I${have_taglib_prefix}/include/taglib" |
| 112 |
fi |
| 113 |
fi |
| 114 |
fi |
| 115 |
if test -n "${TAGLIB_LDFLAGS}"; then |
| 116 |
if test -n "${have_taglib_libs}"; then |
| 117 |
TAGLIB_LDFLAGS="-L${have_taglib_libs} ${TAGLIB_LDFLAGS}" |
| 118 |
fi |
| 119 |
else |
| 120 |
if test -n "${have_taglib_libs}"; then |
| 121 |
TAGLIB_LDFLAGS="-L${have_taglib_libs}" |
| 122 |
else |
| 123 |
if test x"${want_taglib}" = "xauto" \ |
| 124 |
-a x"${ax_check_taglib_taglib_pc}" = "xyes"; then |
| 125 |
TAGLIB_LDFLAGS=" \ |
| 126 |
`${PKG_CONFIG} --libs-only-L taglib` \ |
| 127 |
`${PKG_CONFIG} --libs-only-other taglib` \ |
| 128 |
" |
| 129 |
elif test -n "${have_taglib_prefix}"; then |
| 130 |
TAGLIB_LDFLAGS="-L${have_taglib_prefix}/lib" |
| 131 |
fi |
| 132 |
fi |
| 133 |
fi |
| 134 |
local_cv_have_lib_taglib_opts=yes |
| 135 |
]) |
| 136 |
]) |
| 137 |
|
| 138 |
|
| 139 |
AC_DEFUN([AX_CHECK_TAGLIB], |
| 140 |
[ |
| 141 |
AC_REQUIRE([_AX_CHECK_TAGLIB_OPTS]) |
| 142 |
AC_ARG_VAR([TAGLIB_LIBS], |
| 143 |
[libraries to use for TagLib]) |
| 144 |
AC_CACHE_VAL([local_cv_have_lib_taglib], |
| 145 |
[ |
| 146 |
local_cv_have_lib_taglib=no |
| 147 |
|
| 148 |
if test x"${want_taglib}" != "xno"; then # want_taglib != no |
| 149 |
|
| 150 |
if test -z "${PKG_CONFIG}"; then |
| 151 |
AC_MSG_ERROR([The pkg-config utility is required.], [1]) |
| 152 |
fi |
| 153 |
|
| 154 |
dnl ####### BEGIN CHECK ###### |
| 155 |
PKG_CHECK_EXISTS([taglib $1], [ |
| 156 |
dnl ########################## |
| 157 |
|
| 158 |
libtag_libs_autodetected=no |
| 159 |
if test -z "${TAGLIB_LIBS}"; then |
| 160 |
TAGLIB_LIBS="`${PKG_CONFIG} --libs-only-l taglib`" |
| 161 |
libtag_libs_autodetected=yes |
| 162 |
fi |
| 163 |
|
| 164 |
ax_check_taglib_save_CXXFLAGS="${CXXFLAGS}" |
| 165 |
ax_check_taglib_save_CPPFLAGS="${CPPFLAGS}" |
| 166 |
ax_check_taglib_save_LDFLAGS="${LDFLAGS}" |
| 167 |
ax_check_taglib_save_LIBS="${LIBS}" |
| 168 |
AC_LANG_PUSH([C++]) |
| 169 |
CXXFLAGS="${CXXFLAGS} ${TAGLIB_CFLAGS}" |
| 170 |
CPPFLAGS="${CPPFLAGS} ${TAGLIB_CPPFLAGS}" |
| 171 |
LDFLAGS="${LDFLAGS} ${TAGLIB_LDFLAGS}" |
| 172 |
LIBS="${TAGLIB_LIBS} ${LIBS}" |
| 173 |
AC_CHECK_HEADER([tag.h], |
| 174 |
[ |
| 175 |
AC_MSG_CHECKING([if TagLib works]) |
| 176 |
AC_LINK_IFELSE( |
| 177 |
[AC_LANG_PROGRAM( |
| 178 |
[[ |
| 179 |
#include <tag.h> |
| 180 |
#include <fileref.h> |
| 181 |
]], |
| 182 |
[[ |
| 183 |
TagLib::FileRef f(static_cast<TagLib::File *>(NULL)); |
| 184 |
]] |
| 185 |
)], |
| 186 |
[ |
| 187 |
AC_MSG_RESULT([yes]) |
| 188 |
local_cv_have_lib_taglib=yes |
| 189 |
], |
| 190 |
[ |
| 191 |
AC_MSG_RESULT([no]) |
| 192 |
LIBS="${LIBS} -lstdc++ -lz" |
| 193 |
TAGLIB_LIBS="${TAGLIB_LIBS} -lstdc++ -lz" |
| 194 |
AC_MSG_CHECKING([if TagLib works with -lstdc++ -lz]) |
| 195 |
AC_LINK_IFELSE( |
| 196 |
[AC_LANG_PROGRAM( |
| 197 |
[[ |
| 198 |
#include <tag.h> |
| 199 |
#include <fileref.h> |
| 200 |
]], |
| 201 |
[[ |
| 202 |
TagLib::FileRef f(static_cast<TagLib::File *>(NULL)); |
| 203 |
]] |
| 204 |
)], |
| 205 |
[ |
| 206 |
AC_MSG_RESULT([yes]) |
| 207 |
local_cv_have_lib_taglib=yes |
| 208 |
], |
| 209 |
[ |
| 210 |
AC_MSG_RESULT([no]) |
| 211 |
] |
| 212 |
) |
| 213 |
] |
| 214 |
) |
| 215 |
]) |
| 216 |
CXXFLAGS="${ax_check_taglib_save_CXXFLAGS}" |
| 217 |
CPPFLAGS="${ax_check_taglib_save_CPPFLAGS}" |
| 218 |
LDFLAGS="${ax_check_taglib_save_LDFLAGS}" |
| 219 |
LIBS="${ax_check_taglib_save_LIBS}" |
| 220 |
AC_LANG_POP([C++]) |
| 221 |
|
| 222 |
dnl ####### END CHECK ######## |
| 223 |
], []) |
| 224 |
dnl ########################## |
| 225 |
|
| 226 |
fi # want_taglib != no |
| 227 |
|
| 228 |
]) |
| 229 |
|
| 230 |
AC_MSG_CHECKING([for TagLib]) |
| 231 |
if test x"${local_cv_have_lib_taglib}" = "xyes"; then |
| 232 |
AC_MSG_RESULT([yes]) |
| 233 |
: |
| 234 |
$2 |
| 235 |
else |
| 236 |
AC_MSG_RESULT([no]) |
| 237 |
: |
| 238 |
$3 |
| 239 |
fi |
| 240 |
]) |
| 241 |
|
| 242 |
|
| 243 |
AC_DEFUN([AX_CHECK_TAGLIB_C], |
| 244 |
[ |
| 245 |
AC_REQUIRE([_AX_CHECK_TAGLIB_OPTS]) |
| 246 |
AC_ARG_VAR([TAGLIB_C_LIBS], |
| 247 |
[libraries to use for the TagLib C wrapper]) |
| 248 |
AC_CACHE_VAL([local_cv_have_lib_taglib_c], |
| 249 |
[ |
| 250 |
local_cv_have_lib_taglib_c=no |
| 251 |
|
| 252 |
if test x"${want_taglib}" != "xno"; then # want_taglib != no |
| 253 |
|
| 254 |
if test -z "${PKG_CONFIG}"; then |
| 255 |
AC_MSG_ERROR([The pkg-config utility is required.], [1]) |
| 256 |
fi |
| 257 |
|
| 258 |
dnl ####### BEGIN CHECK ###### |
| 259 |
PKG_CHECK_EXISTS([taglib_c $1], [ |
| 260 |
dnl ########################## |
| 261 |
|
| 262 |
if test -z "${TAGLIB_C_LIBS}"; then |
| 263 |
TAGLIB_C_LIBS="-ltag_c" |
| 264 |
fi |
| 265 |
|
| 266 |
ax_check_taglib_c_save_CFLAGS="${CFLAGS}" |
| 267 |
ax_check_taglib_c_save_CPPFLAGS="${CPPFLAGS}" |
| 268 |
ax_check_taglib_c_save_LDFLAGS="${LDFLAGS}" |
| 269 |
ax_check_taglib_c_save_LIBS="${LIBS}" |
| 270 |
AC_LANG_PUSH([C]) |
| 271 |
CFLAGS="${CFLAGS} ${TAGLIB_CFLAGS}" |
| 272 |
CPPFLAGS="${CPPFLAGS} ${TAGLIB_CPPFLAGS}" |
| 273 |
LDFLAGS="${LDFLAGS} ${TAGLIB_LDFLAGS}" |
| 274 |
LIBS="${TAGLIB_C_LIBS} ${LIBS}" |
| 275 |
AC_CHECK_HEADER([tag_c.h], |
| 276 |
[ |
| 277 |
AC_MSG_CHECKING([if libtag_c works]) |
| 278 |
AC_LINK_IFELSE( |
| 279 |
[AC_LANG_PROGRAM( |
| 280 |
[[ |
| 281 |
#include <tag_c.h> |
| 282 |
]], |
| 283 |
[[ |
| 284 |
taglib_set_string_management_enabled(0); |
| 285 |
]] |
| 286 |
)], |
| 287 |
[ |
| 288 |
AC_MSG_RESULT([yes]) |
| 289 |
local_cv_have_lib_taglib_c=yes |
| 290 |
], |
| 291 |
[ |
| 292 |
AC_MSG_RESULT([no]) |
| 293 |
LIBS="${LIBS} -ltag -lstdc++ -lz" |
| 294 |
TAGLIB_C_LIBS="${TAGLIB_C_LIBS} -ltag -lstdc++ -lz" |
| 295 |
AC_MSG_CHECKING([if libtag_c works with -ltag -lstdc++ -lz]) |
| 296 |
AC_LINK_IFELSE( |
| 297 |
[AC_LANG_PROGRAM( |
| 298 |
[[ |
| 299 |
#include <tag_c.h> |
| 300 |
]], |
| 301 |
[[ |
| 302 |
taglib_set_string_management_enabled(0); |
| 303 |
]] |
| 304 |
)], |
| 305 |
[ |
| 306 |
AC_MSG_RESULT([yes]) |
| 307 |
local_cv_have_lib_taglib_c=yes |
| 308 |
], |
| 309 |
[ |
| 310 |
AC_MSG_RESULT([no]) |
| 311 |
] |
| 312 |
) |
| 313 |
] |
| 314 |
) |
| 315 |
]) |
| 316 |
CFLAGS="${ax_check_taglib_c_save_CFLAGS}" |
| 317 |
CPPFLAGS="${ax_check_taglib_c_save_CPPFLAGS}" |
| 318 |
LDFLAGS="${ax_check_taglib_c_save_LDFLAGS}" |
| 319 |
LIBS="${ax_check_taglib_c_save_LIBS}" |
| 320 |
AC_LANG_POP([C]) |
| 321 |
|
| 322 |
dnl ####### END CHECK ######## |
| 323 |
], []) |
| 324 |
dnl ########################## |
| 325 |
|
| 326 |
fi # want_taglib != no |
| 327 |
|
| 328 |
]) |
| 329 |
|
| 330 |
AC_MSG_CHECKING([for libtag_c]) |
| 331 |
if test x"${local_cv_have_lib_taglib_c}" = "xyes"; then |
| 332 |
AC_MSG_RESULT([yes]) |
| 333 |
: |
| 334 |
$2 |
| 335 |
else |
| 336 |
AC_MSG_RESULT([no]) |
| 337 |
: |
| 338 |
$3 |
| 339 |
fi |
| 340 |
]) |