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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
|
# Configure paths for SID support
dnl -------------------------------------------------------------------------
dnl Try to find a file (or one of more files in a list of dirs).
dnl -------------------------------------------------------------------------
AC_DEFUN([SIDPLAY_FIND_FILE],
[
$3=""
for i in $2; do
for j in $1; do
if test -r "$i/$j"; then
$3=$i
break 2
fi
done
done
])
AC_DEFUN([SIDPLAY_TRY_LINK_SAVE],
[
xs_cxx_save="$CXX"
xs_cxxflags_save="$CXXFLAGS"
xs_ldflags_save="$LDFLAGS"
xs_libs_save="$LIBS"
])
AC_DEFUN([SIDPLAY_TRY_LINK_RESTORE],
[
CXX="$xs_cxx_save"
CXXFLAGS="$xs_cxxflags_save"
LDFLAGS="$xs_ldflags_save"
LIBS="$xs_libs_save"
])
dnl -------------------------------------------------------------------------
dnl Try to find SIDPLAY library and header files.
dnl $xs_have_sidplay1 will be "yes" or "no"
dnl @SIDPLAY1_LDADD@ will be substituted with linker parameters
dnl @SIDPLAY1_INCLUDES@ will be substituted with compiler parameters
dnl -------------------------------------------------------------------------
AC_DEFUN([XS_PATH_LIBSIDPLAY1],
[
AC_MSG_CHECKING([for working SIDPlay1 library and headers])
AC_LANG_PUSH([C++])
# Use include path given by user (if any).
if test -n "$xs_sidplay1_includes"; then
xs_sidplay1_cxxflags="-I$xs_sidplay1_includes"
else
xs_sidplay1_cxxflags=""
fi
# Use library path given by user (if any).
if test -n "$xs_sidplay1_library"; then
xs_sidplay1_ldflags="-L$xs_sidplay1_library"
else
xs_sidplay1_ldflags=""
fi
AC_CACHE_VAL(xs_cv_have_sidplay1,
[
# Run test compilation with either standard search path
# or user-defined paths.
SIDPLAY_TRY_LIBSIDPLAY1
if test "$xs_sidplay1_works" = yes; then
xs_cv_have_sidplay1="xs_have_sidplay1=yes \
xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" \
xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" "
else
SIDPLAY_FIND_LIBSIDPLAY1
fi
])
eval "$xs_cv_have_sidplay1"
if test "$xs_have_sidplay1" = yes; then
if test -n "$xs_sidplay1_cxxflags" || test -n "$xs_sidplay1_ldflags"; then
AC_MSG_RESULT([$xs_sidplay1_cxxflags $xs_sidplay1_ldflags])
else
AC_MSG_RESULT([yes])
fi
SIDPLAY1_LDADD="$xs_sidplay1_ldflags -lsidplay"
SIDPLAY1_INCLUDES="$xs_sidplay1_cxxflags"
AC_SUBST([SIDPLAY1_LDADD])
AC_SUBST([SIDPLAY1_INCLUDES])
else
AC_MSG_RESULT([no])
fi
AC_LANG_POP([C++])
])
dnl Functions used by XS_PATH_LIBSIDPLAY1.
AC_DEFUN([SIDPLAY_FIND_LIBSIDPLAY1],
[
# Search common locations where header files might be stored.
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"
SIDPLAY_FIND_FILE(sidplay/sidtune.h, $xs_sidplay1_incdirs, xs_sidplay1_includes)
# Search common locations where library might be stored.
xs_sidplay1_libdirs="$xs_sidplay1_library /usr/lib /usr/lib/sidplay /usr/local/lib/sidplay /opt/sfw/lib /opt/csw/lib"
SIDPLAY_FIND_FILE(libsidplay.a libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37,
$xs_sidplay1_libdirs, xs_sidplay1_library)
if test -z "$xs_sidplay1_includes" || test -z "$xs_sidplay1_library"; then
xs_cv_have_sidplay1="xs_have_sidplay1=no \
xs_sidplay1_ldflags=\"\" xs_sidplay1_cxxflags=\"\" "
else
# Test compilation with found paths.
xs_sidplay1_ldflags="-L$xs_sidplay1_library"
xs_sidplay1_cxxflags="-I$xs_sidplay1_includes"
SIDPLAY_TRY_LIBSIDPLAY1
xs_cv_have_sidplay1="xs_have_sidplay1=$xs_sidplay1_works \
xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" \
xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" "
fi
])
AC_DEFUN([SIDPLAY_TRY_LIBSIDPLAY1],
[
SIDPLAY_TRY_LINK_SAVE
CXXFLAGS="$CXXFLAGS $xs_sidplay1_cxxflags"
LDFLAGS="$LDFLAGS $xs_sidplay1_ldflags"
LIBS="$LIBS -lsidplay"
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <sidplay/sidtune.h>]],
[[sidTune* myTest = new sidTune(0);]])],
[xs_sidplay1_works=yes],
[xs_sidplay1_works=no]
)
SIDPLAY_TRY_LINK_RESTORE
])
dnl -------------------------------------------------------------------------
dnl Try to find SIDPLAY2 library and header files.
dnl $xs_have_sidplay2 will be "yes" or "no"
dnl @SIDPLAY_LDADD@ will be substituted with linker parameters
dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters
dnl -------------------------------------------------------------------------
AC_DEFUN([XS_PATH_LIBSIDPLAY2],
[
AC_MSG_CHECKING([for working SIDPlay2 library and headers])
AC_LANG_PUSH([C++])
AC_PATH_PROG([PKG_CONFIG], [pkg-config])
if test -n "$PKG_CONFIG" && $PKG_CONFIG --atleast-version $LIBSIDPLAY2_REQUIRED_VERSION libsidplay2; then
xs_pkgcfg_knows=yes
else
xs_pkgcfg_knows=no
fi
# Derive sidbuilders path from libsidplay2 root.
if test -n "$xs_sidplay2_library"; then
xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders"
elif test "$xs_pkgcfg_knows" = yes ; then
xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2`
fi
AC_CACHE_VAL(xs_cv_have_sidplay2,
[
# Run test compilation with either standard search path
# or user-defined paths.
xs_sidplay2_ldadd="-lsidplay2"
SIDPLAY_TRY_LIBSIDPLAY2
if test "$xs_sidplay2_works" = yes; then
xs_cv_have_sidplay2="xs_have_sidplay2=yes \
xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \
xs_sidplay2_ldadd=\"$xs_sidplay2_ldadd\" \
xs_sidplay2_builders=\"$xs_sidplay2_builders\" "
else
SIDPLAY_FIND_LIBSIDPLAY2
fi
])
eval "$xs_cv_have_sidplay2"
if test "$xs_have_sidplay2" = yes; then
if test -n "$xs_sidplay2_cxxflags" || test -n "$xs_sidplay2_ldadd"; then
AC_MSG_RESULT([$xs_sidplay2_cxxflags $xs_sidplay2_ldadd])
else
AC_MSG_RESULT([yes])
fi
SIDPLAY2_LDADD="$xs_sidplay2_ldadd"
SIDPLAY2_INCLUDES="$xs_sidplay2_cxxflags"
AC_SUBST([SIDPLAY2_LDADD])
AC_SUBST([SIDPLAY2_INCLUDES])
else
AC_MSG_RESULT([no])
fi
AC_LANG_POP([C++])
])
dnl Functions used by XS_PATH_LIBSIDPLAY2.
AC_DEFUN([SIDPLAY_FIND_LIBSIDPLAY2],
[
# See whether user didn't provide paths.
if test -z "$xs_sidplay2_includes"; then
if test "$xs_pkgcfg_knows" = yes ; then
xs_sidplay2_includes=`$PKG_CONFIG --variable=includedir libsidplay2`
xs_sidplay2_cxxflags=`$PKG_CONFIG --cflags libsidplay2`
else
# Search common locations where header files might be stored.
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"
SIDPLAY_FIND_FILE(sidplay/sidplay2.h,$xs_sidplay2_incdirs,xs_sidplay2_includes)
xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
fi
else
xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
fi
if test -z "$xs_sidplay2_library"; then
if test "$xs_pkgcfg_knows" = yes ; then
xs_sidplay2_library=`$PKG_CONFIG --variable=libdir libsidplay2`
xs_sidplay2_ldadd=`$PKG_CONFIG --libs libsidplay2`
xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2`
else
# Search common locations where library might be stored.
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"
SIDPLAY_FIND_FILE(libsidplay2.la,$xs_sidplay2_libdirs,xs_sidplay2_library)
xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2"
xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders"
fi
else
xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2"
fi
if test -z "$xs_sidplay2_includes" || test -z "$xs_sidplay2_library"; then
xs_cv_have_sidplay2="xs_have_sidplay2=no \
xs_sidplay2_ldadd=\"\" xs_sidplay2_cxxflags=\"\" \
xs_sidplay2_builders=\"\" "
else
# Test compilation with found paths.
xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2"
xs_sidplay2_cxxflags="-I$xs_sidplay2_includes"
SIDPLAY_TRY_LIBSIDPLAY2
xs_cv_have_sidplay2="xs_have_sidplay2=$xs_sidplay2_works \
xs_sidplay2_ldadd=\"$xs_sidplay2_ldadd\" \
xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \
xs_sidplay2_builders=\"$xs_sidplay2_builders\" "
fi
])
AC_DEFUN([SIDPLAY_TRY_LIBSIDPLAY2],
[
SIDPLAY_TRY_LINK_SAVE
CXXFLAGS="$CXXFLAGS $xs_sidplay2_cxxflags -DHAVE_UNIX"
LDFLAGS="$LDFLAGS $xs_sidplay2_ldadd"
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <sidplay/sidplay2.h>]],
[[sidplay2 *myEngine;]])],
[xs_sidplay2_works=yes],
[xs_sidplay2_works=no]
)
SIDPLAY_TRY_LINK_RESTORE
])
dnl -------------------------------------------------------------------------
dnl Find libsidplay2 builders (sidbuilders) dir.
dnl @BUILDERS_INCLUDES@
dnl @BUILDERS_LDFLAGS@
dnl -------------------------------------------------------------------------
AC_DEFUN([BUILDERS_FIND],
[
AC_MSG_CHECKING([for SIDPlay2 builders directory])
AC_LANG_PUSH([C++])
AC_REQUIRE([XS_PATH_LIBSIDPLAY2])
dnl Be pessimistic.
builders_available=no
dnl Sidbuilder headers are included with "builders" prefix.
builders_includedir=$xs_sidplay2_includes
builders_libdir=$xs_sidplay2_builders
dnl If libsidplay2 is in standard library search path, we need
dnl to get an argument whether /usr, /usr/local, etc. Else we
dnl can only use ${libdir}/sidplay/builders, but then are
dnl unable to check whether files exist as long as ${exec_prefix}
dnl is not defined in the configure script. So, this is a bit
dnl ugly, but a satisfactory fallback default for those who
dnl define ${prefix} and ${exec_prefix}.
if test -z $builders_libdir; then
eval "builders_libdir=$libdir/sidplay/builders"
fi
AC_ARG_WITH(sidbuilders,
[ --with-sidbuilders=DIR what the SIDPlay2 builders install PREFIX is],
[builders_includedir="$withval/include"
builders_libdir="$withval/lib/sidplay/builders"])
AC_ARG_WITH(builders-inc,
[ --with-builders-inc=DIR where the SIDPlay2 builders headers are located],
[builders_includedir="$withval"])
AC_ARG_WITH(builders-lib,
[ --with-builders-lib=DIR where the SIDPlay2 builders libraries are installed],
[builders_libdir="$withval"])
if test -n "$builders_includedir"; then
BUILDERS_INCLUDES="-I$builders_includedir"
fi
if test -n "$builders_libdir"; then
BUILDERS_LDFLAGS="-L$builders_libdir"
fi
if test -d $builders_libdir; then
xs_have_sidbuilders_dir=yes
AC_MSG_RESULT([$builders_libdir])
else
xs_have_sidbuilders_dir=no
AC_MSG_RESULT([$xs_have_sidbuilders_dir])
AC_MSG_ERROR([$builders_libdir not found!
Check --help on how to specify SIDPlay2 and/or builders library and
header path, or set --exec-prefix to the same prefix as your installation
of libsidplay2.
])
fi
AC_SUBST([BUILDERS_INCLUDES])
AC_SUBST([BUILDERS_LDFLAGS])
AC_LANG_POP([C++])
])
dnl -------------------------------------------------------------------------
dnl Test for working reSID builder.
dnl sets $(RESID_LDADD), substitutes @RESID_LDADD@
dnl -------------------------------------------------------------------------
AC_DEFUN([BUILDERS_FIND_RESID],
[
AC_MSG_CHECKING([for reSID builder module])
AC_LANG_PUSH([C++])
SIDPLAY_TRY_LINK_SAVE
CXXFLAGS="$CXXFLAGS $BUILDERS_INCLUDES"
LDFLAGS="$LDFLAGS $BUILDERS_LDFLAGS"
LIBS="$LIBS -lresid-builder"
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <sidplay/builders/resid.h>]],
[[ReSIDBuilder *sid;]])],
[builders_work=yes],
[builders_work=no]
)
SIDPLAY_TRY_LINK_RESTORE
if test "$builders_work" = yes; then
builders_available=yes
xs_builders="reSID $xs_builders"
AC_DEFINE([HAVE_RESID_BUILDER], [], [resid builder])
RESID_LDADD="-lresid-builder"
fi
AC_MSG_RESULT($builders_work)
AC_SUBST([RESID_LDADD])
AC_LANG_POP([C++])
])
dnl -------------------------------------------------------------------------
dnl Test for working HardSID builder.
dnl sets $(HARDSID_LDADD), substitutes @HARDSID_LDADD@
dnl -------------------------------------------------------------------------
AC_DEFUN([BUILDERS_FIND_HARDSID],
[
AC_MSG_CHECKING([for HardSID builder module])
AC_LANG_PUSH([C++])
SIDPLAY_TRY_LINK_SAVE
CXXFLAGS="$CXXFLAGS $BUILDERS_INCLUDES"
LDFLAGS="$LDFLAGS $BUILDERS_LDFLAGS"
LIBS="$LIBS -lhardsid-builder"
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <sidplay/builders/hardsid.h>]],
[[HardSID *sid;]])],
[builders_work=yes],
[builders_work=no]
)
SIDPLAY_TRY_LINK_RESTORE
if test "$builders_work" = yes; then
builders_available=yes
xs_builders="HardSID $xs_builders"
AC_DEFINE([HAVE_HARDSID_BUILDER], [], [harsid builder])
HARDSID_LDADD="-lhardsid-builder"
fi
AC_MSG_RESULT($builders_work)
AC_SUBST([HARDSID_LDADD])
AC_LANG_POP([C++])
])
dnl AM_PATH_SIDPLAY([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for SID libraries, and define SIDPLAY_CFLAGS and SIDPLAY_LIBS
dnl
AC_DEFUN([AM_PATH_SIDPLAY],
[
dnl
dnl Get the cflags and libraries
dnl
dnl ***
dnl *** libSIDPlay 1 options
dnl ***
AC_ARG_WITH(sidplay1,
[ --with-sidplay1=PREFIX Enable SIDPlay1 with install-PREFIX],
[
if test "x$withval" = xyes; then
xs_sidplay1=yes
xs_sidplay1_library=""
xs_sidplay1_includes=""
else
if test "x$withval" = xno; then
xs_sidplay1=no
else
xs_sidplay1=yes
xs_sidplay1_includes="$withval/include"
xs_sidplay1_library="$withval/lib"
fi
fi
],[
xs_sidplay1=try
xs_sidplay1_library=""
xs_sidplay1_includes=""
])
AC_ARG_WITH(sidplay1-inc,
[ --with-sidplay1-inc=DIR Where the SIDPlay1 headers are located],
[xs_sidplay1_includes="$withval"],)
AC_ARG_WITH(sidplay1-lib,
[ --with-sidplay1-lib=DIR Where the SIDPlay1 library is installed],
[xs_sidplay1_library="$withval"],)
dnl ***
dnl *** libSIDPlay 2 options
dnl ***
AC_ARG_WITH(sidplay2,
[ --with-sidplay2=PREFIX Enable SIDPlay2 with install-PREFIX],
[
if test "x$withval" = xyes; then
xs_sidplay2=yes
xs_sidplay2_library=""
xs_sidplay2_includes=""
else
if test "x$withval" = xno; then
xs_sidplay2=no
else
xs_sidplay2=yes
xs_sidplay2_includes="$withval/include"
xs_sidplay2_library="$withval/lib"
fi
fi
],[
xs_sidplay2=try
xs_sidplay2_library=""
xs_sidplay2_includes=""
])
AC_ARG_WITH(sidplay2-inc,
[ --with-sidplay2-inc=DIR Where the SIDPlay2 headers are located],
[xs_sidplay2_includes="$withval"],)
AC_ARG_WITH(sidplay2-lib,
[ --with-sidplay2-lib=DIR Where the SIDPlay2 library is installed],
[xs_sidplay2_library="$withval"],)
dnl ***
dnl *** Determine if libraries are wanted and available
dnl ***
OPT_SIDPLAY1="no"
if test "x$xs_sidplay1" = xtry; then
XS_PATH_LIBSIDPLAY1
else
if test "x$xs_sidplay1" = xyes; then
XS_PATH_LIBSIDPLAY1
if test "x$xs_have_sidplay1" = xno; then
AC_MSG_WARN([libSIDPlay1 library and/or headers were not found!])
fi
fi
fi
if test "x$xs_have_sidplay1" = xyes; then
AC_DEFINE([HAVE_SIDPLAY1],[],[sidplay1 available])
OPT_SIDPLAY1="yes"
fi
OPT_SIDPLAY2="no"
LIBSIDPLAY2_REQUIRED_VERSION="2.1.0"
if test "x$xs_sidplay2" = xtry; then
XS_PATH_LIBSIDPLAY2
else
if test "x$xs_sidplay2" = xyes; then
XS_PATH_LIBSIDPLAY2
if test "x$xs_have_sidplay2" = xno; then
AC_MSG_WARN([libSIDPlay2 library and/or headers were not found!])
fi
fi
fi
if test "x$xs_have_sidplay2" = xyes; then
AC_DEFINE([HAVE_SIDPLAY2],[],[sidplay2 available])
OPT_SIDPLAY2="yes"
BUILDERS_FIND
BUILDERS_FIND_RESID
BUILDERS_FIND_HARDSID
if test "x$builders_available" = xno; then
AC_MSG_WARN([No builder modules were found in the sidbuilders directory!]);
fi
fi
dnl ***
dnl *** Check if we have some emulator library available?
dnl ***
if test "x$OPT_SIDPLAY1" = xno; then
if test "x$OPT_SIDPLAY2" = xno; then
SIDPLAY_HAVESOMETHING="no"
fi
fi
if test "x$SIDPLAY_HAVESOMETHING" = xno; then
ifelse([$2], , :, [$2])
else
ifelse([$1], , :, [$1])
fi
])
|