dnl Include helper macros sinclude([m4/ac_lib_id3.m4]) dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.53) AC_INIT(crossfade.c) AC_CANONICAL_TARGET([]) AM_INIT_AUTOMAKE(xmms-crossfade,0.3.14) AM_CONFIG_HEADER(config.h) dnl autoheader templates, used to be in acconfig.h AH_TEMPLATE([HAVE_OSS], [Defined if OSS is available]) AH_TEMPLATE([HAVE_CTOR], [Defined if the compiler supports the constructor attribute]) AH_TEMPLATE([HAVE_XMMS], [Defined if XMMS headers are available]) AH_TEMPLATE([HAVE_PLAYLIST_GET_FILENAME], [Defined if player supports playlist_get_filename()]) AH_TEMPLATE([HAVE_INPUT_SEEK], [Defined if player supports input_seek()]) AH_TEMPLATE([COMPILE_FOR_XMMS], [Defined if compiling for XMMS]) AH_TEMPLATE([COMPILE_FOR_AUDACIOUS], [Defined if compiling for Audacious]) AH_TEMPLATE([COMPILE_FOR_NOXMMS], [Defined if compiling for noxmms]) AH_TEMPLATE([HAVE_GTK], [Defined if compiling for GTK, set to false for headless]) AH_TEMPLATE([HAVE_GTK_2_0], [Defined if compiling for GTK 2.0 (audacious)]) AH_TEMPLATE([HAVE_IS_QUITTING], [Defined if the 'quitting' patch is present]) AH_TEMPLATE([HAVE_INPUT_STOPPED_FOR_RESTART], [Defined if the 'restart' patch is present]) AH_TEMPLATE([HAVE_GLIB_THREADS], [Defined if glib thread functions are available (GTK 2.0 only)]) AH_TEMPLATE([AUDACIOUS_ABI_VERSION], [Defined to '1' for audacious >=1.3.0 and '2' for >=1.4.0]) dnl save environment settings that could get modified by the tests SAVE_CFLAGS="$CFLAGS" SAVE_LIBS="$LIBS" dnl libtool stuff AC_DISABLE_STATIC AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL dnl endianess AC_C_BIGENDIAN dnl dnl Arguments dnl AC_ARG_ENABLE(player, AS_HELP_STRING([--enable-player], [select media player (xmms, audacious)]), PLAYER=$enableval, PLAYER=xmms) AC_ARG_ENABLE(oss, AS_HELP_STRING([--disable-oss], [disable bultin OSS driver]), oss=$enableval, oss=yes) AC_ARG_ENABLE(samplerate, AS_HELP_STRING([--enable-samplerate], [enable libsamplerate support (default on)]), samplerate=$enableval, samplerate=yes) AC_ARG_ENABLE(fftw, AS_HELP_STRING([--enable-fftw], [enable FFTW test code (default off)]), fftw=$enableval, fftw=no) AC_ARG_ENABLE(id3, AS_HELP_STRING([--enable-id3], [enable libid3 support for reading track number (default off)]), id3=$enableval, id3=no) dnl AC_ARG_ENABLE(userdir, dnl AS_HELP_STRING([--userdir], [install into user plugin dir]), dnl userdir=$enableval, userdir=no) dnl dnl Checks for programs dnl AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PATH_PROG(nmpath, nm) AC_PATH_PROG(XMMS, xmms, no) AC_PATH_PROG(XMMS_CONFIG, xmms-config, no) AC_PATH_PROG(AUDACIOUS, audacious, no) AC_PATH_PROG(PKG_CONFIG, pkg-config, no) AC_PATH_PROG(NOXMMS, noxmms, no) AC_PATH_PROG(NOXMMS_CONFIG, noxmms-config, no) dnl ########################################################################### dnl dnl X Multimedia System dnl dnl ########################################################################### if test "$PLAYER" = xmms then if test "$XMMS" = no then AC_MSG_ERROR([*** xmms not found - please install first ***]) fi if test "$XMMS_CONFIG" = no then AC_MSG_ERROR([*** xmms-config not found - please install first (comes with XMMS > 1.0.0) *** NOTE: If you installed XMMS as a RPM and still get this error, 'xmms-config' might be included in a sperate development RPM instead of the base XMMS package. This depends on the distribution you are using. Look for a RPM called 'libxmms-devel' or 'xmms-devel'. ]) fi PLAYER_GTK2= PLAYER_BIN="$XMMS" PLAYER_BASENAME="xmms" PLAYER_CONFIG="$XMMS_CONFIG" PLAYER_CONFIG_OUTPUT_PLUGIN_DIR="$PLAYER_CONFIG --output-plugin-dir" AM_CONDITIONAL(HAVE_GTK, true) AM_CONDITIONAL(HAVE_GTK_2_0, false) AC_DEFINE(HAVE_GTK) AC_DEFINE(COMPILE_FOR_XMMS) AC_DEFINE(HAVE_PLAYLIST_GET_FILENAME) AC_DEFINE(HAVE_INPUT_SEEK) fi dnl ########################################################################### dnl dnl Audacious dnl dnl ########################################################################### if test "$PLAYER" = audacious then if test "$AUDACIOUS" = no then AC_MSG_ERROR([*** audacious not found - please install first ***]) fi if test "$PKG_CONFIG" == no then AC_MSG_ERROR([*** pkg-config not found]) fi if ! "$PKG_CONFIG" audacious then AC_MSG_ERROR([*** pkg-config audacious not found - please install first *** NOTE: If you installed Audacious as a binary package and get this error, the audacious scripts for 'pkg-config' might be included in a sperate development package. Look for a package called 'audacious-dev'. ]) fi PLAYER_GTK2=yes PLAYER_BIN="$AUDACIOUS" PLAYER_BASENAME="audacious" PLAYER_CONFIG="$PKG_CONFIG audacious" PLAYER_CONFIG_OUTPUT_PLUGIN_DIR="$PLAYER_CONFIG --variable=output_plugin_dir" AM_CONDITIONAL(HAVE_GTK, true) AM_CONDITIONAL(HAVE_GTK_2_0, true) AC_DEFINE(HAVE_GTK) AC_DEFINE(HAVE_GTK_2_0) AC_DEFINE(HAVE_GLIB_THREADS) AC_DEFINE(COMPILE_FOR_AUDACIOUS) AC_CHECK_HEADERS(audacious/configdb.h) AC_CHECK_HEADERS(audacious/plugin.h) if "$PKG_CONFIG" audacious --atleast-version=1.4.0; then if ! "$PKG_CONFIG" audacious --atleast-version=1.4.2; then AC_MSG_ERROR([*** audacious version >= 1.4.2 required *** NOTE: Due to some API changes, you need at least version 1.4.2 of the 1.4 branch of audacious. It includes some additional symbols required by xmms-crossfade. ]) fi AC_DEFINE(AUDACIOUS_ABI_VERSION, 2) audacious_abi_version=2 elif "$PKG_CONFIG" audacious --atleast-version=1.3.0; then AC_DEFINE(AUDACIOUS_ABI_VERSION, 1) audacious_abi_version=1 fi fi dnl ########################################################################### dnl dnl noxmms dnl dnl ########################################################################### if test "$PLAYER" = noxmms then if test "$NOXMMS" = no then AC_MSG_ERROR([*** noxmms not found - please install first ***]) fi if test "$NOXMMS_CONFIG" = no then AC_MSG_ERROR([*** noxmms-config not found - please install first ***]) fi PLAYER_GTK2= PLAYER_BIN="$NOXMMS" PLAYER_BASENAME="noxmms" PLAYER_CONFIG="$NOXMMS_CONFIG" PLAYER_CONFIG_OUTPUT_PLUGIN_DIR="$PLAYER_CONFIG --output-plugin-dir" AM_CONDITIONAL(HAVE_GTK, false) AM_CONDITIONAL(HAVE_GTK_2_0, false) AC_DEFINE(COMPILE_FOR_NOXMMS) AC_DEFINE(HAVE_PLAYLIST_GET_FILENAME) fi dnl ########################################################################### dnl dnl Check if the selected player has been found dnl dnl ########################################################################### if test -z "$PLAYER_CONFIG" then AC_MSG_ERROR([*** no player selected, use --enable-player=xmms|audacious]) fi dnl dnl Path to player -- use the same prefix for installing dnl AC_PREFIX_PROGRAM($PLAYER_BASENAME) dnl ########################################################################### dnl dnl Check for glibc threads implementation (linuxthreads or nptl) dnl dnl ########################################################################### pthreads= LIBC_SO=/lib/libc.so.6 AC_MSG_CHECKING(for glibc threads implementation) if ! test -x "$LIBC_SO"; then result="unknown ($LIBC_SO not found)" elif "$LIBC_SO" | grep -q linuxthreads; then result=linuxthreads pthreads=linuxthreads elif "$LIBC_SO" | grep -q "Native POSIX Threads Library"; then result=NPTL pthreads=nptl else result=unknown fi AC_MSG_RESULT($result) dnl ########################################################################### dnl dnl Check for player patches dnl dnl ########################################################################### AC_MSG_CHECKING([for 'is_quitting' patch in $PLAYER_BIN]) if strings "$PLAYER_BIN" | grep -q -x "is_quitting" then AC_DEFINE(HAVE_IS_QUITTING) exit_patch=found elif test "$PLAYER" == audacious then # not required for audacious, which has a cleanup callback exit_patch="not required for audacious" elif test "$pthreads" == linuxthreads then exit_patch="not required for linuxthreads" else exit_patch="not found" fi AC_MSG_RESULT($exit_patch) if test "$exit_patch" == "not found" then AC_MSG_WARN([*** $PLAYER_BIN is not patched! *** NOTE: For $PLAYER-crossfade to work properly, a patch for $PLAYER itself is required. Without this patch, $PLAYER will lock up or segfault when exitting while a song is being played. This happens only with the NPTL implementation of POSIX threads. See patches/README for details. ]) fi dnl ########################################################################### AC_MSG_CHECKING([for 'songchange' patch in $PLAYER_BIN]) if strings "$PLAYER_BIN" | grep -q -x "input_stopped_for_restart" then AC_DEFINE(HAVE_INPUT_STOPPED_FOR_RESTART) songchange_patch=found elif test "$PLAYER" == audacious then # not required for audacious, which calls flush(0) songchange_patch="not required for audacious" else songchange_patch="not found" fi AC_MSG_RESULT($songchange_patch) if test "$songchange_patch" == "not found" then AC_MSG_WARN([*** $PLAYER_BIN is not patched! *** NOTE: For $PLAYER-crossfade to properly detect songchanges, a patch for $PLAYER is available. See patches/README for details. ]) fi dnl ########################################################################### dnl dnl Checks for GLIB/GTK (either 1.x or 2.0, depending on player) dnl dnl ########################################################################### if test -z "$PLAYER_GTK2" then AM_PATH_GLIB(1.2.7,,AC_MSG_ERROR([*** GLIB >= 1.2.7 not installed - please install first ***])) AM_PATH_GTK(1.2.7,,AC_MSG_ERROR([*** GTK+ >= 1.2.7 not installed - please install first ***]), gthread) else AM_PATH_GLIB_2_0(2.0.0,,AC_MSG_ERROR([*** GLIB >= 2.0.0 not installed - please install first ***])) AM_PATH_GTK_2_0(2.0.0,,AC_MSG_ERROR([*** GTK+ >= 2.0.0 not installed - please install first ***]), gthread) fi dnl ########################################################################### dnl dnl Checks for headers and libraries. dnl dnl ########################################################################### AC_HEADER_STDC AC_CHECK_HEADER(unistd.h) AC_CHECK_HEADER(sys/ioctl.h) AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***])) dnl dnl Check for OSS dnl if test "$oss" = yes then AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h, AC_DEFINE(HAVE_OSS)) if test "$ac_cv_header_sys_soundcard_h" = yes -o \ "$ac_cv_header_machine_soundcard_h" = yes then AM_CONDITIONAL(HAVE_OSS_COND, true) else AM_CONDITIONAL(HAVE_OSS_COND, false) AC_MSG_WARN([*** OSS headers not found, disabling builtin OSS driver ***]) oss=no fi else AM_CONDITIONAL(HAVE_OSS_COND, false) fi AM_CONDITIONAL(HAVE_OSS_COND, test "$oss" = "yes") dnl dnl Check for FFTW dnl if test "$fftw" = yes then AC_CHECK_HEADERS(rfftw.h, AC_CHECK_LIB(fftw, rfftw_create_plan)) if test "$ac_cv_lib_fftw_rfftw_create_plan" != yes then AC_MSG_WARN([*** FFTW headers not found, disabling FFTW test code ***]) fftw=no fi fi AM_CONDITIONAL(HAVE_LIBFFTW_COND, test "$fftw" = "yes") dnl dnl Check for libsamplerate dnl if test "$samplerate" = yes then AC_CHECK_HEADER(samplerate.h, AC_CHECK_LIB(samplerate, src_new)) if test "$ac_cv_lib_samplerate_src_new" != yes then AC_MSG_WARN([*** libsamplerate not found *** NOTE: Secret Rabbit Code (aka libsamplerate) was not found. It is used for high quality resampling. Without it, the builtin resampler will be used, which offers limited quality only. Please get libsamplerate from http://www.mega-nerd.com/SRC/index.html ]) samplerate=no fi fi AM_CONDITIONAL(HAVE_LIBSAMPLERATE_COND, test "$samplerate" = "yes") dnl dnl Check for id3lib dnl if test "$id3" = yes then AC_LIB_ID3 fi dnl ########################################################################### dnl dnl Customize CFLAGS / LIBS dnl dnl ########################################################################### PLAYER_CFLAGS=`$PLAYER_CONFIG --cflags` PLAYER_LIBS=`$PLAYER_CONFIG --libs` if test $HAVE_GTK_TRUE; then XF_CFLAGS="$GLIB_CFLAGS $GTK_CFLAGS $PLAYER_CFLAGS $ID3_CPPFLAGS" XF_LIBS="$GLIB_LIBS $GTK_CFLAGS $PLAYER_LIBS $ID3_LDFLAGS" else XF_CFLAGS="$GLIB_CFLAGS $PLAYER_CFLAGS $ID3_CPPFLAGS" XF_LIBS="$GLIB_LIBS $PLAYER_LIBS $ID3_LDFLAGS" fi dnl dnl Clean up XF_CFLAGS & XF_LIBS (remove duplicate words) dnl -> taken from the configure.in of 'xchat' by Peter Zelezny dnl v0.2.7: Avoiding `tr` due to some compatibility problems dnl AC_PATH_PROG(sortpath, sort) AC_PATH_PROG(uniqpath, uniq) if test ! -z "$sortpath"; then if test ! -z "$uniqpath"; then echo $XF_CFLAGS > cflags rm -f cflags2 for item in $XF_CFLAGS; do echo $item >>cflags2; done sort cflags2 > cflags uniq cflags > cflags2 cat cflags2 | xargs >cflags XF_CFLAGS=`cat cflags` echo $XF_LIBS > cflags rm -f cflags2 for item in $XF_LIBS; do echo $item >>cflags2; done sort cflags2 > cflags uniq cflags > cflags2 cat cflags2 | xargs >cflags XF_LIBS=`cat cflags` rm -f cflags cflags2 fi fi dnl dnl Finally append saved custom CFLAGS/LIBS dnl XF_CFLAGS="$XF_CFLAGS $SAVE_CFLAGS" XF_LIBS="$XF_LIBS $SAVE_LIBS" dnl Make variables visible to the Makefile AC_SUBST(XF_CFLAGS) AC_SUBST(XF_LIBS) dnl ########################################################################### dnl dnl Checks for typedefs, structures, and compiler characteristics. dnl dnl ########################################################################### CFLAGS=$SAVE_CFLAGS LIBS=$SAVE_LIBS AC_MSG_CHECKING(for constructor attribute) if [[ $cross_compiling ]] then result="yes" else AC_TRY_RUN([ void ctor() __attribute__((constructor)); int i=0; void ctor() { i=1; } int main() { return i-1; } ], result="yes", result="no") fi if test "$result" = yes then AC_DEFINE(HAVE_CTOR) fi AC_MSG_RESULT($result) dnl dnl Checks for library functions. dnl AC_FUNC_VPRINTF AC_CHECK_FUNCS(select) LIBS=$XF_LIBS AC_CHECK_FUNCS(g_usleep) AC_CHECK_FUNCS(nanosleep) LIBS=$SAVE_LIBS dnl ########################################################################### dnl dnl Check for output plugin dir dnl dnl ########################################################################### if test ! -d "$libdir" then AC_MSG_CHECKING(for output plugin dir) libdir=`$PLAYER_CONFIG_OUTPUT_PLUGIN_DIR` AC_MSG_RESULT($libdir) fi if test ! -d "$libdir" then AC_CHECK_FILES("${prefix}/lib/$PLAYER/Output" "${prefix}/lib/$PLAYER/Plugins", [libdir="$ac_dir"]) fi if test ! -d "$libdir" then AC_MSG_ERROR([*** No plugin directory found. Use --libdir to specify. ***]) fi dnl Output files AC_OUTPUT(Makefile xmms-crossfade.spec) dnl ########################################################################### dnl dnl Print configuration dnl dnl ########################################################################### echo " Configuration: Compiling for player: $PLAYER_BIN Player Configuration: $PLAYER_CONFIG Install path: $libdir Build OSS driver: $oss 'exit' patch: $exit_patch 'songchange' patch: $songchange_patch Use libsamplerate: $samplerate Use id3lib: $id3 Build FFTW test code: $fftw (testing)" test "$PLAYER" = audacious && echo " Audacious ABI: $audacious_abi_version" echo ""