Debian Codegraph @

m4/libshout.m4

raw
1 dnl # Check for a working installation of libshout.
2 dnl # Provides appropriate --with configuration options, fills the
3 dnl # LIBSHOUT_CFLAGS, LIBSHOUT_CPPFLAGS, LIBSHOUT_LDFLAGS and LIBSHOUT_LIBS
4 dnl # variables accordingly.
5
6
7 dnl # Copyright (c) 2009 Moritz Grimm <[email protected]>
8 dnl #
9 dnl # Permission to use, copy, modify, and distribute this software for any
10 dnl # purpose with or without fee is hereby granted, provided that the above
11 dnl # copyright notice and this permission notice appear in all copies.
12 dnl #
13 dnl # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 dnl # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 dnl # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 dnl # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 dnl # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 dnl # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 dnl # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20
21
22 dnl # For LIBSHOUT_CFLAGS, LIBSHOUT_CPPFLAGS, LIBSHOUT_LDFLAGS and
23 dnl # LIBSHOUT_LIBS:
24 dnl # AX_CHECK_LIBSHOUT([LIBSHOUT-VERSION], [ACTION-IF-FOUND],
25 dnl # [ACTION-IF-NOT-FOUND])
26
27
28 AC_DEFUN([_AX_CHECK_LIBSHOUT_OPTS],
29 [
30 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
31 if test -z "${PKG_CONFIG}"; then
32 AC_MSG_ERROR([The pkg-config utility is required.], [1])
33 fi
34 AC_ARG_VAR([LIBSHOUT_CFLAGS],
35 [C compiler flags for libshout])
36 AC_ARG_VAR([LIBSHOUT_CPPFLAGS],
37 [C preprocessor flags for libshout])
38 AC_ARG_VAR([LIBSHOUT_LDFLAGS],
39 [linker flags for libshout])
40 have_libshout_includes=""
41 have_libshout_libs=""
42 want_libshout="auto"
43 AC_ARG_WITH([libshout],
44 [AS_HELP_STRING([--with-libshout=PFX],
45 [prefix where the libshout header files and library are installed (default: autodetect)])],
46 [
47 case "${withval}" in
48 yes)
49 want_libshout="yes"
50 ;;
51 no)
52 want_libshout="no"
53 ;;
54 *)
55 have_libshout_prefix="${withval}"
56 want_libshout="yes"
57 ;;
58 esac
59 ]
60 )
61 AC_ARG_WITH([libshout-includes],
62 [AS_HELP_STRING([--with-libshout-includes=DIR],
63 [directory where libshout header files are installed (optional)]) ],
64 [
65 case "${withval}" in
66 yes|no) ;;
67 *)
68 have_libshout_includes="${withval}"
69 ;;
70 esac
71 ]
72 )
73 AC_ARG_WITH([libshout-libs],
74 [AS_HELP_STRING([--with-libshout-libs=DIR],
75 [directory where libshout is installed (optional)]) ],
76 [
77 case "${withval}" in
78 yes|no) ;;
79 *)
80 have_libshout_libs="${withval}"
81 ;;
82 esac
83 ]
84 )
85 AC_CACHE_VAL([local_cv_have_lib_libshout_opts],
86 [
87 ax_check_libshout_shout_pc="no"
88 PKG_CHECK_EXISTS([shout], [ax_check_libshout_shout_pc=yes])
89 if test -z "${LIBSHOUT_CFLAGS}" \
90 -a x"${ax_check_libshout_shout_pc}" = "xyes"; then
91 LIBSHOUT_CFLAGS="`${PKG_CONFIG} --cflags-only-other shout`"
92 fi
93 if test -n "${LIBSHOUT_CPPFLAGS}"; then
94 if test -n "${have_libshout_includes}"; then
95 LIBSHOUT_CPPFLAGS="${LIBSHOUT_CPPFLAGS} -I${have_libshout_includes}"
96 fi
97 else
98 if test -n "${have_libshout_includes}"; then
99 LIBSHOUT_CPPFLAGS="-I${have_libshout_includes}"
100 else
101 if test x"${want_libshout}" = "xauto" \
102 -a x"${ax_check_libshout_shout_pc}" = "xyes"; then
103 LIBSHOUT_CPPFLAGS="`${PKG_CONFIG} --cflags-only-I shout`"
104 elif test -n "${have_libshout_prefix}"; then
105 LIBSHOUT_CPPFLAGS="-I${have_libshout_prefix}/include"
106 fi
107 fi
108 fi
109 if test -n "${LIBSHOUT_LDFLAGS}"; then
110 if test -n "${have_libshout_libs}"; then
111 LIBSHOUT_LDFLAGS="-L${have_libshout_libs} ${LIBSHOUT_LDFLAGS}"
112 fi
113 else
114 if test -n "${have_libshout_libs}"; then
115 LIBSHOUT_LDFLAGS="-L${have_libshout_libs}"
116 else
117 if test x"${want_libshout}" = "xauto" \
118 -a x"${ax_check_libshout_shout_pc}" = "xyes"; then
119 LIBSHOUT_LDFLAGS=" \
120 `${PKG_CONFIG} --libs-only-L shout` \
121 `${PKG_CONFIG} --libs-only-other shout` \
122 "
123 elif test -n "${have_libshout_prefix}"; then
124 LIBSHOUT_LDFLAGS="-L${have_libshout_prefix}/lib"
125 fi
126 fi
127 fi
128 local_cv_have_lib_libshout_opts=yes
129 ])
130 ])
131
132
133 AC_DEFUN([AX_CHECK_LIBSHOUT],
134 [
135 AC_REQUIRE([_AX_CHECK_LIBSHOUT_OPTS])
136 AC_REQUIRE([AC_PROG_FGREP])
137 AC_ARG_VAR([LIBSHOUT_LIBS],
138 [libraries to use for libshout])
139 AC_CACHE_VAL([local_cv_have_lib_libshout],
140 [
141 local_cv_have_lib_libshout=no
142
143 if test x"${want_libshout}" != "xno"; then # want_libshout != no
144
145 if test -z "${PKG_CONFIG}"; then
146 AC_MSG_ERROR([The pkg-config utility is required.], [1])
147 fi
148
149 if test -n "$1" -a x"${ax_check_libshout_shout_pc}" = "xyes"; then
150 PKG_CHECK_EXISTS([shout $1], [],
151 [AC_MSG_ERROR([libshout version $1 is required.], [1])]
152 )
153 fi
154
155 libshout_libs_autodetect=no
156 if test -z "${LIBSHOUT_LIBS}" \
157 -a x"${ax_check_libshout_shout_pc}" = "xyes"; then
158 LIBSHOUT_LIBS="`${PKG_CONFIG} --libs-only-l shout`"
159 libshout_libs_autodetect=yes
160 fi
161
162 # If libshout required libm, make sure that it is listed at the end:
163 if test x"${libshout_libs_autodetect}" = x"yes"; then
164 if test -n "`echo ${LIBSHOUT_LIBS} | ${FGREP} -e ' -lm'`"; then
165 xt_shout_TEMP="`echo ${LIBSHOUT_LIBS} | sed -e 's, -lm,,g'`"
166 LIBSHOUT_LIBS="${xt_shout_TEMP} -lm"
167 fi
168 fi
169
170 ax_check_libshout_save_CFLAGS="${CFLAGS}"
171 ax_check_libshout_save_CPPFLAGS="${CPPFLAGS}"
172 ax_check_libshout_save_LDFLAGS="${LDFLAGS}"
173 ax_check_libshout_save_LIBS="${LIBS}"
174 AC_LANG_PUSH([C])
175 CFLAGS="${CFLAGS} ${LIBSHOUT_CFLAGS}"
176 CPPFLAGS="${CPPFLAGS} ${LIBSHOUT_CPPFLAGS}"
177 LDFLAGS="${LDFLAGS} ${LIBSHOUT_LDFLAGS}"
178 LIBS="${LIBSHOUT_LIBS} ${LIBS}"
179 AC_CHECK_HEADER([shout/shout.h],
180 [
181 AC_MSG_CHECKING([if libshout works])
182 AC_LINK_IFELSE(
183 [AC_LANG_PROGRAM(
184 [[
185 #include <shout/shout.h>
186 ]],
187 [[
188 shout_new();
189 ]]
190 )],
191 [
192 AC_MSG_RESULT([yes])
193 local_cv_have_lib_libshout=yes
194 ],
195 [
196 AC_MSG_RESULT([no])
197 if test x"${libshout_libs_autodetect}" = "xyes"; then
198 LIBSHOUT_LIBS="`${PKG_CONFIG} --static --libs-only-l shout`"
199 LIBS="${LIBSHOUT_LIBS} ${ax_check_libshout_save_LIBS}"
200 AC_MSG_CHECKING([if libshout works with explicit dependencies])
201 AC_LINK_IFELSE(
202 [AC_LANG_PROGRAM(
203 [[
204 #include <shout/shout.h>
205 ]],
206 [[
207 shout_new();
208 ]])],
209 [
210 AC_MSG_RESULT([yes])
211 local_cv_have_lib_libshout=yes
212 ],
213 [
214 AC_MSG_RESULT([no])
215 ]
216 )
217 fi
218 ]
219 )
220 ])
221 CFLAGS="${ax_check_libshout_save_CFLAGS}"
222 CPPFLAGS="${ax_check_libshout_save_CPPFLAGS}"
223 LDFLAGS="${ax_check_libshout_save_LDFLAGS}"
224 LIBS="${ax_check_libshout_save_LIBS}"
225 AC_LANG_POP([C])
226
227 fi # want_libshout != no
228
229 ])
230
231 AC_MSG_CHECKING([for libshout $1])
232 if test x"${local_cv_have_lib_libshout}" = "xyes"; then
233 AC_MSG_RESULT([yes])
234 :
235 $2
236 else
237 AC_MSG_RESULT([no])
238 :
239 $3
240 fi
241
242 ])