dnl This can be moved into AC_INIT when AC_PREREQ reaches 2.64. m4_define([AC_PACKAGE_URL],[http://moc.daper.net/]) AC_INIT([Music On Console],[2.5.2],[mocmaint@daper.net],[moc]) AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE AC_PREREQ(2.60) m4_version_prereq([2.64], , [AUTOCONF_DEPRECATED='yes']) dnl This can be removed when AC_PREREQ reaches 2.64. if test -z "$PACKAGE_URL" then AC_SUBST([PACKAGE_URL],['AC_PACKAGE_URL']) AC_DEFINE_UNQUOTED([PACKAGE_URL], ["$PACKAGE_URL"], [Define to the home page for this package.]) fi dnl Capture configuration options for this build. AC_DEFINE_UNQUOTED([CONFIGURATION], ["$ac_configure_args"], [Define to the configuration used to build MOC.]) dnl Capture SVN revision number for this build. AC_PATH_PROG(SVNVERSION, [svnversion]) if test -n "$SVNVERSION" then SVNREVN=`$SVNVERSION -n $srcdir` SVNREVN=`expr "$SVNREVN" : '\([[^:]]*\)'` if test "x$SVNREVN" = "xexported" then unset SVNREVN else echo -n $SVNREVN > REVISION EXTRA_DISTS="$EXTRA_DISTS REVISION" fi fi if test -z "$SVNREVN" && test -f $srcdir/REVISION then SVNREVN=`cat $srcdir/REVISION` EXTRA_DISTS="$EXTRA_DISTS REVISION" fi if test -n "$SVNREVN" then AC_DEFINE_UNQUOTED([PACKAGE_REVISION], ["$SVNREVN"], [The SVN revision of this build.]) fi AC_CANONICAL_HOST AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL dnl Test for an ISO C99 capable compiler so we can warn of pending dnl requirement. save_CC="$CC" AC_PROG_CC_C99 CC="$save_CC" dnl Test for POSIX.1-2001 or better. AC_EGREP_CPP(posix_2001_compliant, [#define _POSIX_C_SOURCE 200112L #include #ifdef _POSIX_VERSION #if _POSIX_VERSION >= 200112L posix_2001_compliant #endif #endif ], [posix_2001_compliant='yes'], [posix_2001_compliant='no']) AC_PROG_AWK AC_LIBTOOL_DLOPEN AC_DISABLE_STATIC AC_ENABLE_SHARED AC_PROG_LIBTOOL AC_LIB_LTDL AC_SUBST([EXTRA_OBJS]) plugindir=$libdir/moc AC_SUBST([plugindir]) PLUGIN_LDFLAGS='-module -avoid-version' AC_SUBST([PLUGIN_LDFLAGS]) OS=`uname 2>/dev/null` case "$host_os" in linux*) AC_DEFINE([LINUX], 1, [Define if your system is GNU/Linux]) ;; openbsd*) AC_DEFINE([OPENBSD], 1, [Define if your system is OpenBSD]) ;; freebsd*) AC_DEFINE([FREEBSD], 1, [Define if your system is FreeBSD]) ;; esac AC_DEFINE([_FILE_OFFSET_BITS], 64, [Use 64bit IO]) AC_HEADER_STDC AC_HEADER_STDBOOL AC_CHECK_HEADERS([fcntl.h string.h strings.h sys/param.h unistd.h sys/un.h \ sys/socket.h sys/types.h signal.h sys/time.h limits.h \ sys/wait.h sys/ioctl.h pwd.h regex.h inttypes.h stdint.h \ time.h errno.h sys/stat.h assert.h locale.h wchar.h],, AC_MSG_ERROR([Can't find required header files.])) AC_CHECK_HEADERS([sys/select.h byteswap.h]) AC_CHECK_FUNCS([sched_get_priority_max]) dnl langinfo AC_CHECK_HEADERS([langinfo.h]) AC_CHECK_HEADERS([nl_types.h]) AC_CHECK_FUNCS([nl_langinfo]) dnl CODESET (taken from vim) AC_MSG_CHECKING(for nl_langinfo(CODESET)) AC_TRY_LINK([ #ifdef HAVE_LANGINFO_H # include #endif ], [char *cs = nl_langinfo(CODESET);], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_NL_LANGINFO_CODESET], 1, [Define if you have CODESET constant]), AC_MSG_RESULT(no)) AC_C_BIGENDIAN dnl Require with iconv for charset translation. AM_ICONV if test "x$am_cv_func_iconv" != xyes; then AC_MSG_ERROR([No iconv library found.]) fi EXTRA_LIBS="$EXTRA_LIBS $LIBICONV" dnl librcc COMPILE_RCC=no AC_ARG_WITH(rcc, AS_HELP_STRING([--without-rcc], [Compile without LIBRCC support])) if test "x$with_rcc" != "xno" then AC_CHECK_HEADERS([librcc.h], [AC_DEFINE([HAVE_RCC], 1, [Define if you have librcc.h]) AC_CHECK_LIB(rcc, rccInit, [RCC_LIBS="-lrcc" AC_SUBST([RCC_LIBS]) COMPILE_RCC=yes]) ]) fi AC_C_CONST AC_C_FLEXIBLE_ARRAY_MEMBER AC_C_INLINE AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_TYPE_INTPTR_T AC_C99_FUNC_LRINTF AX_CFLAGS_GCC_OPTION(-Wall) AX_CFLAGS_GCC_OPTION(-W) PKG_PROG_PKG_CONFIG([0.20]) if test "x$PKG_CONFIG" = "x" then AC_MSG_WARN([No pkg-config utility found or it's too old, I will have trouble finding installed libraries.]) fi AC_ARG_ENABLE(cache, AS_HELP_STRING([--enable-cache], [Enable tags caching code])) if test "x$enable_cache" != "xno" then AX_PATH_BDB([4.1], [], [BDB4_DEPRECATED="yes"]) AX_PATH_BDB([4], [ EXTRA_LIBS="$EXTRA_LIBS $BDB_LIBS" LDFLAGS="$LDFLAGS $BDB_LDFLAGS" CPPFLAGS="$CPPFLAGS $BDB_CPPFLAGS" ], AC_MSG_ERROR([BerkeleyDB (libdb) not found.])) fi AC_ARG_WITH(oss, AS_HELP_STRING([--without-oss], [Compile without OSS support])) if test "x$with_oss" != "xno" then OSSLIBDIR="$with_oss" if test "x$with_oss" = "x" || test "x$with_oss" = "xyes" then OSSLIBDIR="/usr/lib/oss" if test -f "/etc/oss.conf" then . /etc/oss.conf fi fi if test -d "$OSSLIBDIR/include" then OSS_CFLAGS="-I$OSSLIBDIR/include" fi save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $OSS_CFLAGS" AC_CHECK_HEADERS([sys/soundcard.h soundcard.h]) CPPFLAGS="$save_CPPFLAGS" if test "$ac_cv_header_sys_soundcard_h" = "yes" -o \ "$ac_cv_header_soundcard_h" = "yes" then AC_DEFINE([HAVE_OSS], 1, [Define if you have OSS.]) EXTRA_OBJS="$EXTRA_OBJS oss.o" CFLAGS="$CFLAGS $OSS_CFLAGS" SOUND_DRIVERS="$SOUND_DRIVERS OSS" AC_CHECK_LIB([ossaudio], [_oss_ioctl], [EXTRA_LIBS="$EXTRA_LIBS -lossaudio"]) fi fi AC_ARG_WITH(sndio, AS_HELP_STRING([--without-sndio], [Compile without SNDIO support])) if test "x$with_sndio" != "xno" then AC_CHECK_HEADERS([sndio.h]) if test "$ac_cv_header_sndio_h" = "yes" then AC_DEFINE([HAVE_SNDIO], 1, [Define if you have SNDIO.]) EXTRA_OBJS="$EXTRA_OBJS sndio_out.o" SOUND_DRIVERS="$SOUND_DRIVERS SNDIO" AC_CHECK_LIB([sndio], [sio_open], [EXTRA_LIBS="$EXTRA_LIBS -lsndio"]) fi fi AC_ARG_WITH(alsa, AS_HELP_STRING([--without-alsa], [Compile without ALSA support])) COMPILE_ALSA="no" if test "x$with_alsa" != "xno" then PKG_CHECK_MODULES(ALSA, [alsa >= 0.9], [SOUND_DRIVERS="$SOUND_DRIVERS ALSA" EXTRA_OBJS="$EXTRA_OBJS alsa.o" AC_DEFINE([HAVE_ALSA], 1, [Define if you have ALSA.]) EXTRA_LIBS="$EXTRA_LIBS $ALSA_LIBS" CFLAGS="$CFLAGS $ALSA_CFLAGS" if ! $PKG_CONFIG --atleast-version 1.0.11 alsa then ALSA_DEPRECATED="yes" fi COMPILE_ALSA="yes" need_usleep="yes"], [true]) fi AC_ARG_WITH(jack, AS_HELP_STRING([--without-jack], [Compile without JACK support])) if test "x$with_jack" != "xno" then PKG_CHECK_MODULES(JACK, [jack >= 0.4], [SOUND_DRIVERS="$SOUND_DRIVERS JACK" EXTRA_OBJS="$EXTRA_OBJS jack.o" AC_DEFINE([HAVE_JACK], 1, [Define if you have JACK.]) EXTRA_LIBS="$EXTRA_LIBS $JACK_LIBS" CFLAGS="$CFLAGS $JACK_CFLAGS" AC_SEARCH_LIBS(jack_client_open, jack, [AC_DEFINE([HAVE_JACK_CLIENT_OPEN], 1, [Define to 1 if you have the `jack_client_open' function.])]) need_usleep="yes"], [true]) fi AC_SUBST([SOUNDDRIVER]) case "$host_os" in openbsd*) SOUNDDRIVER="SNDIO:JACK:OSS";; *) SOUNDDRIVER="JACK:ALSA:OSS";; esac AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [Enable debugging code])) if test "x$enable_debug" = "xno" then AC_DEFINE([NDEBUG], 1, [Define if you don't want debugging code]) COMPILE_DEBUG='no' else if test "x$enable_debug" = "xgdb" then AX_CFLAGS_GCC_OPTION([-ggdb]) AX_CFLAGS_GCC_OPTION([-O0]) COMPILE_DEBUG='gdb' fi if test "x$ac_cv_cflags_gcc_option__ggdb" = "x" then AX_CFLAGS_GCC_OPTION([-g]) COMPILE_DEBUG='yes' fi EXTRA_OBJS="$EXTRA_OBJS null_out.o md5.o" need_usleep="yes" fi AC_FUNC_MALLOC AC_FUNC_STAT AC_CHECK_FUNCS([getcwd memmove strcasecmp strdup strerror strncasecmp strchr \ strrchr socket gettimeofday getenv fork setsid kill bind listen \ accept time connect unlink send recv select strftime access freopen \ localtime_r mbsrtowcs mbstowcs execvp wcswidth strspn geteuid],, AC_MSG_ERROR([Required standard C/UNIX functions are not present.])) AC_CHECK_FUNC([sin], , [AC_CHECK_LIB([m], [sin], , AC_MSG_ERROR([No sin() function found.])) EXTRA_LIBS="$EXTRA_LIBS -lm"]) AC_CHECK_FUNC([sinh], , [AC_CHECK_LIB([m], [sinh], , AC_MSG_ERROR([No sinh() function found.])) EXTRA_LIBS="$EXTRA_LIBS -lm"]) dnl optional functions AC_CHECK_FUNCS([strcasestr strerror_r syslog]) AX_CHECK_UNAME_SYSCALL if test "x$need_usleep" = "xyes" then AC_CHECK_FUNC([usleep], , AC_MSG_ERROR([No usleep() function found.])) fi dnl MIME magic AC_ARG_WITH(magic, AS_HELP_STRING([--without-magic], [Compile without MIME magic support])) COMPILE_MAGIC="no" if test "x$with_magic" != "xno" then AC_CHECK_LIB(magic, magic_open, [COMPILE_MAGIC="yes" AC_DEFINE([HAVE_LIBMAGIC], 1, [Define if you have libmagic.]) EXTRA_LIBS="$EXTRA_LIBS -lmagic"]) fi dnl FIXME: Support for this in the source code AC_HEADER_DIRENT ACX_PTHREAD AC_FUNC_MMAP if test "$ax_pthread_ok" != "yes" then AC_MSG_ERROR([[I don't know how to compile pthreads code on this system.]]) fi CC="$PTHREAD_CC" CFLAGS="$PTHREAD_CFLAGS $CFLAGS" EXTRA_LIBS="$EXTRA_LIBS $PTHREAD_LIBS" AC_CHECK_FUNCS([getrlimit pthread_attr_getstacksize]) dnl __FUNCTION__ AC_TRY_COMPILE(,[printf(__FUNCTION__);], [AC_DEFINE([HAVE__FUNCTION__], 1, [Define if we have __FUNCTION__ constant])]) dnl __attribute__ AC_TRY_COMPILE([#include ], [int f(const char *f, ...) __attribute__((format (printf, 1, 2)))], [AC_DEFINE([HAVE__ATTRIBUTE__], 1, [Define if we have __attribute__ extension])]) dnl ncurses dnl This 'unset' circumvents a notified bug in AX_WITH_CURSES when dnl _PKG_CONFIG succeeds but a stale 'pkg_failed' value is checked. dnl It can be removed once an updated 'ax_with_curses.m4' is committed. unset pkg_failed AX_WITH_CURSES if test "x$ax_cv_curses" != "xyes" then AC_MSG_ERROR([You need curses/ncurses library and header files.]) else AC_CHECK_LIB([$CURSES_LIB], [set_escdelay], AC_DEFINE([HAVE_SET_ESCDELAY], 1, [Define if you have set_escdelay.]), [AC_CHECK_FUNC([setenv], , AC_MSG_ERROR([Required function setenv not found.]))]) EXTRA_LIBS="$EXTRA_LIBS $CURSES_LIB" fi EXTRA_LIBS="$EXTRA_LIBS $CURSES_LIBS" dnl Remove -D_GNU_SOURCE as it causes problems when defined mid-configure. for flag in $CURSES_CFLAGS do if test "x$flag" != "x-D_GNU_SOURCE" then CPPFLAGS="$CPPFLAGS $flag" fi done AC_RUN_LOG([: The test below is actually for set_escdelay in curses library.]) AC_RUN_LOG([: Using 'm' avoids unpacking CURSES_LIBS.]) AC_CHECK_LIB([m], [set_escdelay], AC_DEFINE([HAVE_SET_ESCDELAY], 1, [Define if you have set_escdelay.]), [], [$CURSES_LIBS]) dnl popt AC_CHECK_LIB([popt], [poptGetContext], [true], [POPT_MISSING="yes"]) dnl getopt AC_CHECK_FUNC(getopt_long, [AC_CHECK_HEADERS([getopt.h],,[AC_MSG_ERROR([You need getopt.h.])])], [#FreeBSD has it there AC_CHECK_LIB(gnugetopt,getopt_long,, [AC_LIBOBJ(getopt) AC_LIBOBJ(getopt1) AC_CONFIG_LINKS([getopt.h:gnugetopt.h])] )] ) dnl samplerate AC_ARG_WITH(samplerate, AS_HELP_STRING([--without-samplerate], [Compile without libsamplerate])) COMPILE_SAMPLERATE="no" if test "x$with_samplerate" != "xno" then PKG_CHECK_MODULES(samplerate, samplerate >= 0.1.0, [EXTRA_LIBS="$EXTRA_LIBS $samplerate_LIBS" CFLAGS="$CFLAGS $samplerate_CFLAGS" AC_DEFINE([HAVE_SAMPLERATE], 1, [Define if you have libsamplerate]) COMPILE_SAMPLERATE="yes"], [true]) fi dnl Decoder plugins m4_include(decoder_plugins/decoders.m4) dnl curl COMPILE_CURL="no" AC_ARG_WITH(curl, AS_HELP_STRING([--without-curl], [Compile without Network streams support])) if test "x$with_curl" != "xno" then dnl FIXME: make a better curl test AC_CHECK_PROG([CURL_CONFIG], [curl-config], [yes]) if test "x$CURL_CONFIG" = "xyes" then AC_MSG_CHECKING([libcurl version]) curl_ver=`curl-config --version | $AWK '{print $2}'` curl_ver_major=`echo $curl_ver | $AWK -F. '{print $1}'` curl_ver_minor=`echo $curl_ver | $AWK -F. '{print $2}'` curl_ver_fix=`echo $curl_ver | $AWK -F. '{print $3}'` # make 071202 from 7.12.2 curl_ver_number=`printf "%02d%02d%02d" $curl_ver_major \ $curl_ver_minor $curl_ver_fix` if test "$curl_ver_number" -lt "071501" then CURL_DEPRECATED="yes" fi if test "$curl_ver_number" -ge "071202" then AC_MSG_RESULT([$curl_ver, OK]) CFLAGS="$CFLAGS `curl-config --cflags`" EXTRA_LIBS="$EXTRA_LIBS `curl-config --libs`" EXTRA_OBJS="$EXTRA_OBJS io_curl.o" AC_DEFINE([HAVE_CURL], 1, [Define if you have libcurl]) COMPILE_CURL="yes" else AC_MSG_RESULT([$curl_ver, but minimum is 7.12.2]) fi fi fi dnl Check for XZ. AC_CHECK_PROG([XZ_MISSING], [xz], [no], [yes]) AC_SUBST(EXTRA_LIBS) AC_SUBST(EXTRA_DISTS) AC_OUTPUT([Makefile themes/Makefile config.example ]) echo echo "-----------------------------------------------------------------------" echo "MOC will be compiled with:" echo if test `echo $DECODER_PLUGINS | $AWK '{print(length())}'` -le 50 then echo "Decoder plugins: $DECODER_PLUGINS" else DECODERS_IX=`echo $DECODER_PLUGINS | $AWK '{match(substr($0, 1, 51), /.* /);print(RLENGTH)}'` DECODERS_1=`echo $DECODER_PLUGINS | $AWK "{print(substr(\\$0, 1, $DECODERS_IX - 1))}"` DECODERS_2=`echo $DECODER_PLUGINS | $AWK "{print(substr(\\$0, $DECODERS_IX + 1))}"` echo "Decoder plugins: $DECODERS_1" echo " $DECODERS_2" fi echo "Sound Drivers: "$SOUND_DRIVERS echo "DEBUG: "$COMPILE_DEBUG echo "RCC: "$COMPILE_RCC echo "Network streams: "$COMPILE_CURL echo "Resampling: "$COMPILE_SAMPLERATE echo "MIME magic: "$COMPILE_MAGIC echo "-----------------------------------------------------------------------" echo if test "x$AUTOCONF_DEPRECATED" = "xyes" then echo "WARNING: After release 2.5 MOC will require Autoconf version" echo " 2.64 or later. Plan to upgrade your Autoconf soon." echo fi if test "x$posix_2001_compliant" = "xno" then echo "WARNING: After release 2.5, MOC will require a POSIX.1-2001" echo " compliant system; plan to upgrade your system soon." echo fi if test "x$ac_cv_prog_cc_c99" = "xno" then echo "WARNING: After release 2.5 MOC will require an ISO C99 capable" echo " compiler. Plan to upgrade your compiler soon." echo fi if test "x$FFMPEG_CONFIG" = "xyes" then echo "WARNING: Use of Debian's ffmpeg-config is deprecated;" echo " please upgrade FFmpeg or it's libraries to a version" echo " using pkg-config (FFmpeg release 0.5 or later)." echo fi if test "x$BDB4_DEPRECATED" = "xyes" then echo "WARNING: After release 2.5 MOC will require Berkeley DB release" echo " 4.1 or later. Plan to upgrade your libraries soon." echo fi if test "x$CURL_DEPRECATED" = "xyes" then echo "WARNING: After release 2.5 MOC will require libcurl version" echo " 7.15.1 or later. Plan to upgrade your libraries soon." echo fi if test "x$ALSA_DEPRECATED" = "xyes" then echo "WARNING: After release 2.5 MOC will require ALSA version 1.0.11" echo " or later. Plan to upgrade your ALSA soon." echo fi if test "x$FFMPEG_DEPRECATED" = "xyes" then echo "WARNING: After version 2.5, MOC will require FFmpeg/LibAV version" echo " 1.0/10.0 or later. Plan to upgrade your libraries soon." echo fi if test "x$FLAC_DEPRECATED" = "xyes" then echo "WARNING: After release 2.5 MOC will require FLAC release 1.1.3 or" echo " later. Plan to upgrade your libraries soon." echo fi if test "x$POPT_MISSING" = "xyes" then echo "WARNING: After release 2.5 MOC will require libpopt. Plan" echo " to install it before moving on from release 2.5." echo fi if test "x$XZ_MISSING" = "xyes" then echo "WARNING: After release 2.5 MOC will use XZ to create tarballs" echo " by default. If you wish to build tarballs, either plan" echo " to install XZ soon or start using explicit 'dist-*'" echo " 'make' targets." echo fi if test "x$UPGRADE_TAGLIB" = "xyes" then echo "WARNING: MOC will soon require TagLib version 1.5 or later;" echo " plan to upgrade your TagLib soon." echo fi if test "x$UPGRADE_MUSEPACK" = "xyes" then echo "WARNING: MOC will soon require Musepack libmpc (rather than libmpcdec);" echo " plan to upgrade your Musepack soon." echo fi if test "x$DECODER_PLUGINS" = "x" then echo "WARNING: No decoder plugins are to be compiled;" echo " you will have to provide them separately." echo fi if test "x$SOUND_DRIVERS" = "x" then echo "WARNING: No sound output methods are to be compiled;" echo " you will not hear any sound!" echo fi if test "x$COMPILE_SAMPLERATE" = "xno" -a "x$COMPILE_ALSA" = "xyes" then echo "WARNING: Without libsamplerate, the 'ALSAStutterDefeat' option" echo " may severely restrict the number of audios playable." echo fi echo "WARNING: Since MOC version 2 the executable file name has changed to mocp!" echo " Please remove old moc binary if you have installed an older version." echo