comparison m4/sidplay.m4 @ 0:13389e613d67 trunk

[svn] - initial import of audacious-plugins tree (lots to do)
author nenolod
date Mon, 18 Sep 2006 01:11:49 -0700
parents
children f0c34c3b61c0
comparison
equal deleted inserted replaced
-1:000000000000 0:13389e613d67
1 # Configure paths for SID support
2
3 dnl -------------------------------------------------------------------------
4 dnl Try to find a file (or one of more files in a list of dirs).
5 dnl -------------------------------------------------------------------------
6
7 AC_DEFUN([SIDPLAY_FIND_FILE],
8 [
9 $3=""
10 for i in $2; do
11 for j in $1; do
12 if test -r "$i/$j"; then
13 $3=$i
14 break 2
15 fi
16 done
17 done
18 ])
19
20 AC_DEFUN([SIDPLAY_TRY_LINK_SAVE],
21 [
22 xs_cxx_save="$CXX"
23 xs_cxxflags_save="$CXXFLAGS"
24 xs_ldflags_save="$LDFLAGS"
25 xs_libs_save="$LIBS"
26 ])
27
28
29 AC_DEFUN([SIDPLAY_TRY_LINK_RESTORE],
30 [
31 CXX="$xs_cxx_save"
32 CXXFLAGS="$xs_cxxflags_save"
33 LDFLAGS="$xs_ldflags_save"
34 LIBS="$xs_libs_save"
35 ])
36
37
38 dnl -------------------------------------------------------------------------
39 dnl Try to find SIDPLAY library and header files.
40 dnl $xs_have_sidplay1 will be "yes" or "no"
41 dnl @SIDPLAY1_LDADD@ will be substituted with linker parameters
42 dnl @SIDPLAY1_INCLUDES@ will be substituted with compiler parameters
43 dnl -------------------------------------------------------------------------
44
45 AC_DEFUN([XS_PATH_LIBSIDPLAY1],
46 [
47 AC_MSG_CHECKING([for working SIDPlay1 library and headers])
48
49 AC_LANG_PUSH([C++])
50
51 # Use include path given by user (if any).
52 if test -n "$xs_sidplay1_includes"; then
53 xs_sidplay1_cxxflags="-I$xs_sidplay1_includes"
54 else
55 xs_sidplay1_cxxflags=""
56 fi
57
58 # Use library path given by user (if any).
59 if test -n "$xs_sidplay1_library"; then
60 xs_sidplay1_ldflags="-L$xs_sidplay1_library"
61 else
62 xs_sidplay1_ldflags=""
63 fi
64
65 AC_CACHE_VAL(xs_cv_have_sidplay1,
66 [
67 # Run test compilation with either standard search path
68 # or user-defined paths.
69 SIDPLAY_TRY_LIBSIDPLAY1
70 if test "$xs_sidplay1_works" = yes; then
71 xs_cv_have_sidplay1="xs_have_sidplay1=yes \
72 xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" \
73 xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" "
74 else
75 SIDPLAY_FIND_LIBSIDPLAY1
76 fi
77 ])
78
79 eval "$xs_cv_have_sidplay1"
80
81 if test "$xs_have_sidplay1" = yes; then
82 if test -n "$xs_sidplay1_cxxflags" || test -n "$xs_sidplay1_ldflags"; then
83 AC_MSG_RESULT([$xs_sidplay1_cxxflags $xs_sidplay1_ldflags])
84 else
85 AC_MSG_RESULT([yes])
86 fi
87
88 SIDPLAY1_LDADD="$xs_sidplay1_ldflags -lsidplay"
89 SIDPLAY1_INCLUDES="$xs_sidplay1_cxxflags"
90 AC_SUBST([SIDPLAY1_LDADD])
91 AC_SUBST([SIDPLAY1_INCLUDES])
92 else
93 AC_MSG_RESULT([no])
94 fi
95
96 AC_LANG_POP([C++])
97 ])
98
99 dnl Functions used by XS_PATH_LIBSIDPLAY1.
100
101 AC_DEFUN([SIDPLAY_FIND_LIBSIDPLAY1],
102 [
103 # Search common locations where header files might be stored.
104 xs_sidplay1_incdirs="$xs_sidplay1_includes /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include /opt/sfw/include /opt/csw/include"
105 SIDPLAY_FIND_FILE(sidplay/sidtune.h, $xs_sidplay1_incdirs, xs_sidplay1_includes)
106
107 # Search common locations where library might be stored.
108 xs_sidplay1_libdirs="$xs_sidplay1_library /usr/lib /usr/lib/sidplay /usr/local/lib/sidplay /opt/sfw/lib /opt/csw/lib"
109 SIDPLAY_FIND_FILE(libsidplay.a libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37,
110 $xs_sidplay1_libdirs, xs_sidplay1_library)
111
112 if test -z "$xs_sidplay1_includes" || test -z "$xs_sidplay1_library"; then
113 xs_cv_have_sidplay1="xs_have_sidplay1=no \
114 xs_sidplay1_ldflags=\"\" xs_sidplay1_cxxflags=\"\" "
115 else
116 # Test compilation with found paths.
117 xs_sidplay1_ldflags="-L$xs_sidplay1_library"
118 xs_sidplay1_cxxflags="-I$xs_sidplay1_includes"
119 SIDPLAY_TRY_LIBSIDPLAY1
120 xs_cv_have_sidplay1="xs_have_sidplay1=$xs_sidplay1_works \
121 xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" \
122 xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" "
123 fi
124 ])
125
126 AC_DEFUN([SIDPLAY_TRY_LIBSIDPLAY1],
127 [
128 SIDPLAY_TRY_LINK_SAVE
129
130 CXXFLAGS="$CXXFLAGS $xs_sidplay1_cxxflags"
131 LDFLAGS="$LDFLAGS $xs_sidplay1_ldflags"
132 LIBS="$LIBS -lsidplay"
133
134 AC_LINK_IFELSE([AC_LANG_PROGRAM(
135 [[#include <sidplay/sidtune.h>]],
136 [[sidTune* myTest = new sidTune(0);]])],
137 [xs_sidplay1_works=yes],
138 [xs_sidplay1_works=no]
139 )
140
141 SIDPLAY_TRY_LINK_RESTORE
142 ])
143
144
145
146
147
148 dnl -------------------------------------------------------------------------
149 dnl Try to find SIDPLAY2 library and header files.
150 dnl $xs_have_sidplay2 will be "yes" or "no"
151 dnl @SIDPLAY_LDADD@ will be substituted with linker parameters
152 dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters
153 dnl -------------------------------------------------------------------------
154 AC_DEFUN([XS_PATH_LIBSIDPLAY2],
155 [
156 AC_MSG_CHECKING([for working SIDPlay2 library and headers])
157
158 AC_LANG_PUSH([C++])
159
160 AC_PATH_PROG([PKG_CONFIG], [pkg-config])
161 if test -n "$PKG_CONFIG" && $PKG_CONFIG --atleast-version $LIBSIDPLAY2_REQUIRED_VERSION libsidplay2; then
162 xs_pkgcfg_knows=yes
163 else
164 xs_pkgcfg_knows=no
165 fi
166
167 # Derive sidbuilders path from libsidplay2 root.
168 if test -n "$xs_sidplay2_library"; then
169 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders"
170 elif test "$xs_pkgcfg_knows" = yes ; then
171 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2`
172 fi
173
174 AC_CACHE_VAL(xs_cv_have_sidplay2,
175 [
176 # Run test compilation with either standard search path
177 # or user-defined paths.
178 xs_sidplay2_ldadd="-lsidplay2"
179 SIDPLAY_TRY_LIBSIDPLAY2
180 if test "$xs_sidplay2_works" = yes; then
181 xs_cv_have_sidplay2="xs_have_sidplay2=yes \
182 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \
183 xs_sidplay2_ldadd=\"$xs_sidplay2_ldadd\" \
184 xs_sidplay2_builders=\"$xs_sidplay2_builders\" "
185 else
186 SIDPLAY_FIND_LIBSIDPLAY2
187 fi
188 ])
189 eval "$xs_cv_have_sidplay2"
190 if test "$xs_have_sidplay2" = yes; then
191 if test -n "$xs_sidplay2_cxxflags" || test -n "$xs_sidplay2_ldadd"; then
192 AC_MSG_RESULT([$xs_sidplay2_cxxflags $xs_sidplay2_ldadd])
193 else
194 AC_MSG_RESULT([yes])
195 fi
196
197 SIDPLAY2_LDADD="$xs_sidplay2_ldadd"
198 SIDPLAY2_INCLUDES="$xs_sidplay2_cxxflags"
199 AC_SUBST([SIDPLAY2_LDADD])
200 AC_SUBST([SIDPLAY2_INCLUDES])
201 else
202 AC_MSG_RESULT([no])
203 fi
204
205 AC_LANG_POP([C++])
206 ])
207
208
209 dnl Functions used by XS_PATH_LIBSIDPLAY2.
210 AC_DEFUN([SIDPLAY_FIND_LIBSIDPLAY2],
211 [
212 # See whether user didn't provide paths.
213 if test -z "$xs_sidplay2_includes"; then
214 if test "$xs_pkgcfg_knows" = yes ; then
215 xs_sidplay2_includes=`$PKG_CONFIG --variable=includedir libsidplay2`
216 xs_sidplay2_cxxflags=`$PKG_CONFIG --cflags libsidplay2`
217 else
218 # Search common locations where header files might be stored.
219 xs_sidplay2_incdirs="$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"
220 SIDPLAY_FIND_FILE(sidplay/sidplay2.h,$xs_sidplay2_incdirs,xs_sidplay2_includes)
221 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
222 fi
223 else
224 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
225 fi
226 if test -z "$xs_sidplay2_library"; then
227 if test "$xs_pkgcfg_knows" = yes ; then
228 xs_sidplay2_library=`$PKG_CONFIG --variable=libdir libsidplay2`
229 xs_sidplay2_ldadd=`$PKG_CONFIG --libs libsidplay2`
230 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2`
231 else
232 # Search common locations where library might be stored.
233 xs_sidplay2_libdirs="$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"
234 SIDPLAY_FIND_FILE(libsidplay2.la,$xs_sidplay2_libdirs,xs_sidplay2_library)
235 xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2"
236 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders"
237 fi
238 else
239 xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2"
240 fi
241 if test -z "$xs_sidplay2_includes" || test -z "$xs_sidplay2_library"; then
242 xs_cv_have_sidplay2="xs_have_sidplay2=no \
243 xs_sidplay2_ldadd=\"\" xs_sidplay2_cxxflags=\"\" \
244 xs_sidplay2_builders=\"\" "
245 else
246 # Test compilation with found paths.
247 xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2"
248 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
249 SIDPLAY_TRY_LIBSIDPLAY2
250 xs_cv_have_sidplay2="xs_have_sidplay2=$xs_sidplay2_works \
251 xs_sidplay2_ldadd=\"$xs_sidplay2_ldadd\" \
252 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \
253 xs_sidplay2_builders=\"$xs_sidplay2_builders\" "
254 fi
255 ])
256
257
258 AC_DEFUN([SIDPLAY_TRY_LIBSIDPLAY2],
259 [
260 SIDPLAY_TRY_LINK_SAVE
261
262 CXXFLAGS="$CXXFLAGS $xs_sidplay2_cxxflags -DHAVE_UNIX"
263 LDFLAGS="$LDFLAGS $xs_sidplay2_ldadd"
264
265 AC_LINK_IFELSE([AC_LANG_PROGRAM(
266 [[#include <sidplay/sidplay2.h>]],
267 [[sidplay2 *myEngine;]])],
268 [xs_sidplay2_works=yes],
269 [xs_sidplay2_works=no]
270 )
271
272 SIDPLAY_TRY_LINK_RESTORE
273 ])
274
275
276 dnl -------------------------------------------------------------------------
277 dnl Find libsidplay2 builders (sidbuilders) dir.
278 dnl @BUILDERS_INCLUDES@
279 dnl @BUILDERS_LDFLAGS@
280 dnl -------------------------------------------------------------------------
281 AC_DEFUN([BUILDERS_FIND],
282 [
283 AC_MSG_CHECKING([for SIDPlay2 builders directory])
284
285 AC_LANG_PUSH([C++])
286
287 AC_REQUIRE([XS_PATH_LIBSIDPLAY2])
288
289 dnl Be pessimistic.
290 builders_available=no
291
292 dnl Sidbuilder headers are included with "builders" prefix.
293 builders_includedir=$xs_sidplay2_includes
294 builders_libdir=$xs_sidplay2_builders
295
296 dnl If libsidplay2 is in standard library search path, we need
297 dnl to get an argument whether /usr, /usr/local, etc. Else we
298 dnl can only use ${libdir}/sidplay/builders, but then are
299 dnl unable to check whether files exist as long as ${exec_prefix}
300 dnl is not defined in the configure script. So, this is a bit
301 dnl ugly, but a satisfactory fallback default for those who
302 dnl define ${prefix} and ${exec_prefix}.
303 if test -z $builders_libdir; then
304 eval "builders_libdir=$libdir/sidplay/builders"
305 fi
306
307 AC_ARG_WITH(sidbuilders,
308 [ --with-sidbuilders=DIR what the SIDPlay2 builders install PREFIX is],
309 [builders_includedir="$withval/include"
310 builders_libdir="$withval/lib/sidplay/builders"])
311
312 AC_ARG_WITH(builders-inc,
313 [ --with-builders-inc=DIR where the SIDPlay2 builders headers are located],
314 [builders_includedir="$withval"])
315
316 AC_ARG_WITH(builders-lib,
317 [ --with-builders-lib=DIR where the SIDPlay2 builders libraries are installed],
318 [builders_libdir="$withval"])
319
320 if test -n "$builders_includedir"; then
321 BUILDERS_INCLUDES="-I$builders_includedir"
322 fi
323
324 if test -n "$builders_libdir"; then
325 BUILDERS_LDFLAGS="-L$builders_libdir"
326 fi
327
328 if test -d $builders_libdir; then
329 xs_have_sidbuilders_dir=yes
330 AC_MSG_RESULT([$builders_libdir])
331 else
332 xs_have_sidbuilders_dir=no
333 AC_MSG_RESULT([$xs_have_sidbuilders_dir])
334 AC_MSG_ERROR([$builders_libdir not found!
335 Check --help on how to specify SIDPlay2 and/or builders library and
336 header path, or set --exec-prefix to the same prefix as your installation
337 of libsidplay2.
338 ])
339 fi
340
341 AC_SUBST([BUILDERS_INCLUDES])
342 AC_SUBST([BUILDERS_LDFLAGS])
343
344 AC_LANG_POP([C++])
345 ])
346
347
348 dnl -------------------------------------------------------------------------
349 dnl Test for working reSID builder.
350 dnl sets $(RESID_LDADD), substitutes @RESID_LDADD@
351 dnl -------------------------------------------------------------------------
352 AC_DEFUN([BUILDERS_FIND_RESID],
353 [
354 AC_MSG_CHECKING([for reSID builder module])
355 AC_LANG_PUSH([C++])
356 SIDPLAY_TRY_LINK_SAVE
357
358 CXXFLAGS="$CXXFLAGS $BUILDERS_INCLUDES"
359 LDFLAGS="$LDFLAGS $BUILDERS_LDFLAGS"
360 LIBS="$LIBS -lresid-builder"
361
362 AC_LINK_IFELSE([AC_LANG_PROGRAM(
363 [[#include <sidplay/builders/resid.h>]],
364 [[ReSIDBuilder *sid;]])],
365 [builders_work=yes],
366 [builders_work=no]
367 )
368
369 SIDPLAY_TRY_LINK_RESTORE
370
371 if test "$builders_work" = yes; then
372 builders_available=yes
373 xs_builders="reSID $xs_builders"
374 AC_DEFINE([HAVE_RESID_BUILDER], [], [resid builder])
375 RESID_LDADD="-lresid-builder"
376 fi
377 AC_MSG_RESULT($builders_work)
378 AC_SUBST([RESID_LDADD])
379 AC_LANG_POP([C++])
380 ])
381
382
383 dnl -------------------------------------------------------------------------
384 dnl Test for working HardSID builder.
385 dnl sets $(HARDSID_LDADD), substitutes @HARDSID_LDADD@
386 dnl -------------------------------------------------------------------------
387 AC_DEFUN([BUILDERS_FIND_HARDSID],
388 [
389 AC_MSG_CHECKING([for HardSID builder module])
390 AC_LANG_PUSH([C++])
391 SIDPLAY_TRY_LINK_SAVE
392
393 CXXFLAGS="$CXXFLAGS $BUILDERS_INCLUDES"
394 LDFLAGS="$LDFLAGS $BUILDERS_LDFLAGS"
395 LIBS="$LIBS -lhardsid-builder"
396
397 AC_LINK_IFELSE([AC_LANG_PROGRAM(
398 [[#include <sidplay/builders/hardsid.h>]],
399 [[HardSID *sid;]])],
400 [builders_work=yes],
401 [builders_work=no]
402 )
403
404 SIDPLAY_TRY_LINK_RESTORE
405
406 if test "$builders_work" = yes; then
407 builders_available=yes
408 xs_builders="HardSID $xs_builders"
409 AC_DEFINE([HAVE_HARDSID_BUILDER], [], [harsid builder])
410 HARDSID_LDADD="-lhardsid-builder"
411 fi
412 AC_MSG_RESULT($builders_work)
413 AC_SUBST([HARDSID_LDADD])
414 AC_LANG_POP([C++])
415 ])
416
417
418 dnl AM_PATH_SIDPLAY([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
419 dnl Test for SID libraries, and define SIDPLAY_CFLAGS and SIDPLAY_LIBS
420 dnl
421 AC_DEFUN([AM_PATH_SIDPLAY],
422 [
423 dnl
424 dnl Get the cflags and libraries
425 dnl
426
427 dnl ***
428 dnl *** libSIDPlay 1 options
429 dnl ***
430 AC_ARG_WITH(sidplay1,
431 [ --with-sidplay1=PREFIX Enable SIDPlay1 with install-PREFIX],
432 [
433 if test "x$withval" = xyes; then
434 xs_sidplay1=yes
435 xs_sidplay1_library=""
436 xs_sidplay1_includes=""
437 else
438 if test "x$withval" = xno; then
439 xs_sidplay1=no
440 else
441 xs_sidplay1=yes
442 xs_sidplay1_includes="$withval/include"
443 xs_sidplay1_library="$withval/lib"
444 fi
445 fi
446 ],[
447 xs_sidplay1=try
448 xs_sidplay1_library=""
449 xs_sidplay1_includes=""
450 ])
451
452 AC_ARG_WITH(sidplay1-inc,
453 [ --with-sidplay1-inc=DIR Where the SIDPlay1 headers are located],
454 [xs_sidplay1_includes="$withval"],)
455
456 AC_ARG_WITH(sidplay1-lib,
457 [ --with-sidplay1-lib=DIR Where the SIDPlay1 library is installed],
458 [xs_sidplay1_library="$withval"],)
459
460 dnl ***
461 dnl *** libSIDPlay 2 options
462 dnl ***
463 AC_ARG_WITH(sidplay2,
464 [ --with-sidplay2=PREFIX Enable SIDPlay2 with install-PREFIX],
465 [
466 if test "x$withval" = xyes; then
467 xs_sidplay2=yes
468 xs_sidplay2_library=""
469 xs_sidplay2_includes=""
470 else
471 if test "x$withval" = xno; then
472 xs_sidplay2=no
473 else
474 xs_sidplay2=yes
475 xs_sidplay2_includes="$withval/include"
476 xs_sidplay2_library="$withval/lib"
477 fi
478 fi
479 ],[
480 xs_sidplay2=try
481 xs_sidplay2_library=""
482 xs_sidplay2_includes=""
483 ])
484
485 AC_ARG_WITH(sidplay2-inc,
486 [ --with-sidplay2-inc=DIR Where the SIDPlay2 headers are located],
487 [xs_sidplay2_includes="$withval"],)
488
489
490 AC_ARG_WITH(sidplay2-lib,
491 [ --with-sidplay2-lib=DIR Where the SIDPlay2 library is installed],
492 [xs_sidplay2_library="$withval"],)
493
494 dnl ***
495 dnl *** Determine if libraries are wanted and available
496 dnl ***
497 OPT_SIDPLAY1="no"
498 if test "x$xs_sidplay1" = xtry; then
499 XS_PATH_LIBSIDPLAY1
500 else
501 if test "x$xs_sidplay1" = xyes; then
502 XS_PATH_LIBSIDPLAY1
503 if test "x$xs_have_sidplay1" = xno; then
504 AC_MSG_WARN([libSIDPlay1 library and/or headers were not found!])
505 fi
506 fi
507 fi
508 if test "x$xs_have_sidplay1" = xyes; then
509 AC_DEFINE([HAVE_SIDPLAY1],[],[sidplay1 available])
510 OPT_SIDPLAY1="yes"
511 fi
512
513 OPT_SIDPLAY2="no"
514 LIBSIDPLAY2_REQUIRED_VERSION="2.1.0"
515 if test "x$xs_sidplay2" = xtry; then
516 XS_PATH_LIBSIDPLAY2
517 else
518 if test "x$xs_sidplay2" = xyes; then
519 XS_PATH_LIBSIDPLAY2
520 if test "x$xs_have_sidplay2" = xno; then
521 AC_MSG_WARN([libSIDPlay2 library and/or headers were not found!])
522 fi
523 fi
524 fi
525 if test "x$xs_have_sidplay2" = xyes; then
526 AC_DEFINE([HAVE_SIDPLAY2],[],[sidplay2 available])
527 OPT_SIDPLAY2="yes"
528 BUILDERS_FIND
529 BUILDERS_FIND_RESID
530 BUILDERS_FIND_HARDSID
531 if test "x$builders_available" = xno; then
532 AC_MSG_WARN([No builder modules were found in the sidbuilders directory!]);
533 fi
534 fi
535
536
537 dnl ***
538 dnl *** Check if we have some emulator library available?
539 dnl ***
540 if test "x$OPT_SIDPLAY1" = xno; then
541 if test "x$OPT_SIDPLAY2" = xno; then
542 SIDPLAY_HAVESOMETHING="no"
543 fi
544 fi
545
546 if test "x$SIDPLAY_HAVESOMETHING" = xno; then
547 ifelse([$2], , :, [$2])
548 else
549 ifelse([$1], , :, [$1])
550 fi
551
552 ])