comparison acinclude.m4 @ 744:c7fa50576c70

Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as they seem to call it.) Also removed support for the "old" libSIDPlay2 API, only supporting the "new" CVS trunk COMI API for the old libSIDPlay2. We'll see how that goes ..
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 05 Nov 2012 17:24:16 +0200
parents c310c2a01a31
children 3e305ce076e8
comparison
equal deleted inserted replaced
743:99ed62858072 744:c7fa50576c70
41 m4_ifvaln([$3], [LDFLAGS="$xs_ldflags_save"])dnl 41 m4_ifvaln([$3], [LDFLAGS="$xs_ldflags_save"])dnl
42 m4_ifvaln([$4], [LIBS="$xs_libs_save"])dnl 42 m4_ifvaln([$4], [LIBS="$xs_libs_save"])dnl
43 ]) 43 ])
44 44
45 45
46 AC_DEFUN([XS_LIB_RESULT],
47 [
48 define([Name], [translit([$1], [a-z], [A-Z])])dnl
49 if test "x$xs_have_$1" = "xyes"; then
50 if test "x$xs_$1_cxxflags" != "x" || test "x$xs_$1_ldflags" != "x"; then
51 AC_MSG_RESULT([$xs_$1_cxxflags $2 $xs_$1_ldflags $3])
52 else
53 AC_MSG_RESULT([yes])
54 fi
55
56 Name[]_LIBS="$xs_$1_ldflags $2"
57 Name[]_CFLAGS="$xs_$1_cxxflags $3"
58 AC_SUBST(Name[]_LIBS)dnl
59 AC_SUBST(Name[]_CFLAGS)dnl
60 else
61 AC_MSG_RESULT([no])
62 fi
63 ])
64
65
66 AC_DEFUN([XS_PROG_PKGCONFIG],
67 [
68 AC_PATH_PROG([PKG_CONFIG], [pkg-config])dnl
69 ])
70
71
72 AC_DEFUN([XS_ARG_WITH], [dnl 46 AC_DEFUN([XS_ARG_WITH], [dnl
73 define([Name], [translit([$1], [a-z], [A-Z])])dnl 47 define([Name], [translit([$1], [a-z], [A-Z])])dnl
74 define([roflCopter], [Enable $2 with install-PREFIX])dnl 48 define([roflCopter], [Enable $2 with install-PREFIX])dnl
75 AH_TEMPLATE(HAVE_[]Name, [Define if you have and want to use $2])dnl 49 AH_TEMPLATE(HAVE_[]Name, [Define if you have and want to use $2])dnl
76 AC_ARG_WITH([$1], 50 AC_ARG_WITH([$1],
154 else 128 else
155 XS_FIND_LIBSIDPLAY1 129 XS_FIND_LIBSIDPLAY1
156 fi 130 fi
157 ]) 131 ])
158 eval "$xs_cv_have_sidplay1" 132 eval "$xs_cv_have_sidplay1"
159 XS_LIB_RESULT([sidplay1], [-lsidplay], []) 133
134 if test "x$xs_have_sidplay1" = "xyes"; then
135 if test "x$xs_sidplay1_cxxflags" != "x" || test "x$xs_sidplay1_ldflags" != "x"; then
136 AC_MSG_RESULT([$xs_sidplay1_cxxflags $xs_sidplay1_ldflags -lsidplay])
137 else
138 AC_MSG_RESULT([yes])
139 fi
140
141 SIDPLAY1_LIBS="$xs_sidplay1_ldflags -lsidplay"
142 SIDPLAY1_CFLAGS="$xs_sidplay1_cxxflags"
143 AC_SUBST([SIDPLAY1_LIBS])dnl
144 AC_SUBST([SIDPLAY1_CFLAGS])dnl
145 else
146 AC_MSG_RESULT([no])
147 fi
160 AC_LANG_POP([C++]) 148 AC_LANG_POP([C++])
161 ]) 149 ])
162 150
163 dnl Functions used by XS_PATH_LIBSIDPLAY1. 151 dnl Functions used by XS_PATH_LIBSIDPLAY1.
164 152
199 dnl @SIDPLAY_LIBS@ will be substituted with linker parameters 187 dnl @SIDPLAY_LIBS@ will be substituted with linker parameters
200 dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters 188 dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters
201 dnl ------------------------------------------------------------------------- 189 dnl -------------------------------------------------------------------------
202 AC_DEFUN([XS_PATH_LIBSIDPLAY2], 190 AC_DEFUN([XS_PATH_LIBSIDPLAY2],
203 [ 191 [
204 AC_MSG_CHECKING([for working SIDPlay2 library and headers]) 192 AC_MSG_CHECKING([for working SIDPlay2/FP library and headers])
205 193
206 AC_LANG_PUSH([C++]) 194 AC_LANG_PUSH([C++])
207 195
208 AC_REQUIRE([XS_PROG_PKGCONFIG]) 196 PKG_CHECK_EXISTS([libsidplay2 >= 2.1.1], [xs_pkg_sidplay2="yes"], [])
209 if test "x$PKG_CONFIG" != "x" && $PKG_CONFIG --atleast-version m4_ifval([$1], [$1], [2.1.0]) libsidplay2; then 197 PKG_CHECK_EXISTS([libsidplayfp >= 0.3.7], [xs_pkg_sidplayfp="yes"], [])
210 xs_pkgcfg_knows="yes" 198
211 else 199 if test "x$xs_pkg_sidplayfp" = "xyes"; then
212 xs_pkgcfg_knows="no" 200 AC_CACHE_VAL([xs_cv_have_sidplayfp],
213 fi 201 [
214 202 xs_sidplay2_cflags=`$PKG_CONFIG --libs libsidplayfp`
215 dnl Derive sidbuilders path from libsidplay2 root. 203 xs_sidplay2_ldflags=`$PKG_CONFIG --libs libsidplayfp`
216 if test "x$xs_sidplay2_library" != "x"; then 204
217 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders" 205 XS_TRY_LIBRARY([sidplay2],
218 elif test "x$xs_pkgcfg_knows" = "xyes" ; then 206 [$xs_sidplay2_cxxflags -DHAVE_UNIX], [$xs_sidplay2_ldflags],
219 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2` 207 [sidplayfp], [sidplayfp/sidplay2.h], [sidplay2 *myEngine;])
220 fi 208
221 209 if test "x$xs_sidplay2_works" = "xyes"; then
222 AC_CACHE_VAL([xs_cv_have_sidplay2], 210 xs_cv_have_sidplay2="xs_have_sidplayfp=yes \
223 [ 211 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \
224 dnl Run test compilation with either standard search path 212 xs_sidplay2_ldflags=\"$xs_sidplay2_ldflags\""
225 dnl or user-defined paths. 213 fi
226 xs_sidplay2_ldflags="-lsidplay2" 214 ])
227 XS_TRY_LIBSIDPLAY2 215
228 if test "x$xs_sidplay2_works" = "xyes"; then 216 elif test "x$xs_pkg_sidplay2" = "xyes"; then
229 xs_cv_have_sidplay2="xs_have_sidplay2=yes \ 217
230 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \ 218 AC_CACHE_VAL([xs_cv_have_sidplay2],
231 xs_sidplay2_ldflags=\"$xs_sidplay2_ldflags\" \ 219 [
232 xs_sidplay2_builders=\"$xs_sidplay2_builders\" " 220 xs_sidplay2_cflags=`$PKG_CONFIG --libs libsidplay2`
221 xs_sidplay2_ldflags=`$PKG_CONFIG --libs libsidplay2`
222
223 dnl Derive sidbuilders path from libsidplay2 root.
224 if test "x$xs_sidplay2_library" != "x"; then
225 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders"
226 else
227 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2`
228 fi
229
230 dnl *** Check for new COMI API
231 xs_api_ok="no"
232 AC_MSG_CHECKING([libSIDPlay2 API compatibility])
233 tmp_CPPFLAGS="$CPPFLAGS"
234 if test -d "$xs_sidplay2_includes"; then
235 CPPFLAGS="$CPPFLAGS -I${xs_sidplay2_includes}"
236 fi
237 AC_EGREP_HEADER([::Iid], [sidplay/sidplay2.h],
238 [xs_have_sidplay2_api="yes"], [
239 AC_EGREP_HEADER([SIDIID], [sidplay/sidplay2.h], [
240 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sidplay/sidunknown.h>], [ISidUnknown *i;])], [xs_api_ok="yes"], [])])
241 ])
242
243 if test "x$xs_api_ok" = "xyes"; then
244 XS_TRY_LIBRARY([sidplay2],
245 [$xs_sidplay2_cxxflags -DHAVE_UNIX], [$xs_sidplay2_ldflags],
246 [sidplay2], [sidplay/sidplay2.h], [sidplay2 *myEngine;])
247 fi
248
249 if test "x$xs_sidplay2_works" = "xyes"; then
250 xs_cv_have_sidplay2="xs_have_sidplay2=yes \
251 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \
252 xs_sidplay2_ldflags=\"$xs_sidplay2_ldflags\" \
253 xs_sidplay2_builders=\"$xs_sidplay2_builders\" "
254 fi
255 ])
256 fi
257
258 eval "$xs_cv_have_sidplay2"
259 eval "$xs_cv_have_sidplayfp"
260
261 if test "x$xs_have_sidplay2" = "xyes" -o "x$xs_have_sidplayfp" = "xyes"; then
262 if test "x$xs_sidplay2_cxxflags" != "x" || test "x$xs_sidplay2_ldflags" != "x"; then
263 AC_MSG_RESULT([$xs_sidplay2_cxxflags $xs_sidplay2_ldflags])
233 else 264 else
234 XS_FIND_LIBSIDPLAY2 265 AC_MSG_RESULT([yes])
235 fi 266 fi
236 ]) 267
237 eval "$xs_cv_have_sidplay2" 268 SIDPLAY2_LIBS="$xs_sidplay2_ldflags"
238 XS_LIB_RESULT([sidplay2], [], []) 269 SIDPLAY2_CFLAGS="$xs_sidplay2_cxxflags"
270 AC_SUBST([SIDPLAY2_LIBS])dnl
271 AC_SUBST([SIDPLAY2_CFLAGS])dnl
272 else
273 AC_MSG_RESULT([no])
274 fi
275
239 AC_LANG_POP([C++]) 276 AC_LANG_POP([C++])
240 ])
241
242
243 dnl Functions used by XS_PATH_LIBSIDPLAY2.
244 AC_DEFUN([XS_FIND_LIBSIDPLAY2],
245 [
246 dnl See whether user didn't provide paths.
247 if test "x$xs_sidplay2_includes" = "x"; then
248 if test "x$xs_pkgcfg_knows" = "xyes" ; then
249 xs_sidplay2_includes=`$PKG_CONFIG --variable=includedir libsidplay2`
250 xs_sidplay2_cxxflags=`$PKG_CONFIG --cflags libsidplay2`
251 else
252 dnl Search common locations where header files might be stored.
253 XS_FIND_FILE([xs_sidplay2_includes], [sidplay/sidplay2.h],
254 [$xs_sidplay2_includes $xs_sidplay2_includes/include /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include /opt/sfw/include /opt/csw/include])
255 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
256 fi
257 else
258 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
259 fi
260 if test "x$xs_sidplay2_library" = "x"; then
261 if test "x$xs_pkgcfg_knows" = "xyes" ; then
262 xs_sidplay2_library=`$PKG_CONFIG --variable=libdir libsidplay2`
263 xs_sidplay2_ldflags=`$PKG_CONFIG --libs libsidplay2`
264 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2`
265 else
266 dnl Search common locations where library might be stored.
267 XS_FIND_FILE([xs_sidplay2_library], [libsidplay2.la],
268 [$xs_sidplay2_library $xs_sidplay2_library/lib $xs_sidplay2_library/src /usr/lib /usr/lib/sidplay /usr/local/lib/sidplay /opt/sfw/lib /opt/csw/lib])
269 xs_sidplay2_ldflags="-L$xs_sidplay2_library -lsidplay2"
270 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders"
271 fi
272 else
273 xs_sidplay2_ldflags="-L$xs_sidplay2_library -lsidplay2"
274 fi
275 if test "x$xs_sidplay2_includes" = "x" || test "x$xs_sidplay2_library" = "x"; then
276 xs_cv_have_sidplay2="xs_have_sidplay2=no \
277 xs_sidplay2_ldflags=\"\" xs_sidplay2_cxxflags=\"\" \
278 xs_sidplay2_builders=\"\" "
279 else
280 dnl Test compilation with found paths.
281 xs_sidplay2_ldflags="-L$xs_sidplay2_library -lsidplay2"
282 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
283 XS_TRY_LIBSIDPLAY2
284 xs_cv_have_sidplay2="xs_have_sidplay2=$xs_sidplay2_works \
285 xs_sidplay2_ldflags=\"$xs_sidplay2_ldflags\" \
286 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \
287 xs_sidplay2_builders=\"$xs_sidplay2_builders\" "
288 fi
289 ])
290
291
292 AC_DEFUN([XS_TRY_LIBSIDPLAY2],
293 [
294 XS_TRY_LIBRARY([sidplay2],
295 [$xs_sidplay2_cxxflags -DHAVE_UNIX], [$xs_sidplay2_ldflags],
296 [sidplay2], [sidplay/sidplay2.h], [sidplay2 *myEngine;])
297 ]) 277 ])
298 278
299 279
300 dnl ------------------------------------------------------------------------- 280 dnl -------------------------------------------------------------------------
301 dnl Find libsidplay2 builders (sidbuilders) dir. 281 dnl Find libsidplay2 builders (sidbuilders) dir.