--- qsampler/trunk/configure.ac 2015/05/23 16:48:20 2766 +++ qsampler/trunk/configure.ac 2016/11/10 16:23:30 3038 @@ -1,19 +1,69 @@ # Process this file with autoconf to produce a configure script. -AC_INIT(Qsampler, 0.3.0.2, rncbc@rncbc.org, qsampler) +AC_INIT(Qsampler, 0.4.1.10, rncbc@rncbc.org, qsampler) AC_CONFIG_SRCDIR(src/qsampler.cpp) AC_CONFIG_HEADERS(src/config.h) AC_CONFIG_FILES(Makefile qsampler.spec src/src.pri src/qsampler.desktop) +# Build date and time. +AC_CACHE_VAL([ac_cv_build_date], + [ac_cv_build_date=$(date +"%b %d %Y %H:%M %z")]) +ac_build_date="$ac_cv_build_date" +AC_DEFINE_UNQUOTED(CONFIG_BUILD_DATE, ["$ac_build_date"], [Build date and time.]) + +# Build version string. +AC_CACHE_VAL([ac_cv_build_version], [ + ac_cv_build_version=$(git describe --tags --abbrev=6 2>/dev/null) + if test -n "$ac_cv_build_version"; then + ac_cv_build_version=$(echo $ac_cv_build_version | sed -r 's/^[[^_]]+_//') + ac_cv_build_version=$(echo $ac_cv_build_version | sed -r 's/-g/git./') + ac_cv_build_version=$(echo $ac_cv_build_version | sed -r 's/[[_|-]]+/./g') + else + ac_cv_build_version=$PACKAGE_VERSION + fi +]) +ac_build_version="$ac_cv_build_version" +AC_DEFINE_UNQUOTED(CONFIG_BUILD_VERSION, ["$ac_build_version"], [Build version string.]) + +# Sanitized version string. +AC_CACHE_VAL([ac_cv_version], [ + ac_cv_version=$(echo $ac_cv_build_version | sed -r 's/^([[0-9|\.]]+).*$/\1/') +]) +ac_version="$ac_cv_version" +AC_DEFINE_UNQUOTED(CONFIG_VERSION, ["$ac_version"], [Version string.]) +AC_SUBST(ac_version) + # Set default installation prefix. AC_PREFIX_DEFAULT(/usr/local) -ac_prefix=$prefix -if test "x$ac_prefix" = "xNONE"; then - ac_prefix=$ac_default_prefix +if test "x$prefix" = "xNONE"; then + prefix=$ac_default_prefix +fi +if test "x$exec_prefix" = "xNONE"; then + exec_prefix=$prefix fi +eval ac_prefix=$prefix AC_SUBST(ac_prefix) AC_DEFINE_UNQUOTED(CONFIG_PREFIX, ["$ac_prefix"], [Default installation prefix.]) +# Set default installation directories. +eval ac_bindir=$bindir +AC_SUBST(ac_bindir) +AC_DEFINE_UNQUOTED(CONFIG_BINDIR, ["$ac_bindir"], [Default executable binary path.]) + +eval ac_libdir=$libdir +AC_SUBST(ac_libdir) +AC_DEFINE_UNQUOTED(CONFIG_LIBDIR, ["$ac_libdir"], [Default object library path.]) + +eval datarootdir=$datarootdir +eval ac_datadir=$datadir +AC_SUBST(ac_datadir) +AC_DEFINE_UNQUOTED(CONFIG_DATADIR, ["$ac_datadir"], [Default arch-idependent data path.]) + +eval ac_mandir=$mandir +AC_SUBST(ac_mandir) +AC_DEFINE_UNQUOTED(CONFIG_MANDIR, ["$ac_mandir"], [Default man page path.]) + + # Enable debugging argument option. AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable debugging (default=no)]), @@ -32,15 +82,9 @@ # Enable Qt4/5 availability. AC_ARG_ENABLE(qt4, - AC_HELP_STRING([--enable-qt4], [enable Qt4 build (default=yes)]), + AC_HELP_STRING([--enable-qt4], [enable Qt4 build (default=no)]), [ac_qt4="$enableval"], - [ac_qt4="yes"]) - -AC_ARG_ENABLE(qt5, - AC_HELP_STRING([--enable-qt5], [enable Qt5 build (default=no)]), - [ac_qt5="$enableval"], - [ac_qt5="no"]) - + [ac_qt4="no"]) # Enable libgig availability. @@ -49,6 +93,12 @@ [ac_libgig="$enableval"], [ac_libgig="yes"]) +# Enable X11 unique/single instance. +AC_ARG_ENABLE(xunique, + AC_HELP_STRING([--enable-xunique], [enable X11 unique/single instance (default=yes)]), + [ac_xunique="$enableval"], + [ac_xunique="yes"]) + # Enable debugger stack-trace option (assumes --enable-debug). AC_ARG_ENABLE(stacktrace, AC_HELP_STRING([--enable-stacktrace], [enable debugger stack-trace (default=no)]), @@ -56,11 +106,7 @@ # Standard installation base dirs. -if test "$cross_compiling" = yes; then - ac_with_paths="" -else - ac_with_paths="/usr/local /usr" -fi +ac_with_paths="" # Set for alternate Qt4/5 installation dir. AC_ARG_WITH(qt4, @@ -78,13 +124,6 @@ if test "x$ac_qt5_path" != "xno"; then ac_with_paths="$ac_with_paths $ac_qt5_path" - ac_qt5="yes" -fi - -if test "x$ac_qt4" = "xno"; then - ac_qt5="yes" -fi -if test "x$ac_qt5" = "xyes"; then ac_qt4="no" fi @@ -105,84 +144,136 @@ # Checks for programs. -AC_PROG_CC AC_PROG_CPP AC_PROG_CXX AC_PROG_CXXCPP -AC_PROG_GCC_TRADITIONAL # Checks for languages. -AC_LANG_C AC_LANG_CPLUSPLUS +# Check for pkg-config. PKG_PROG_PKG_CONFIG -# Check for proper flags. -ac_arch=`uname -m` - -# Check for some a-la-debian alternatives... -ac_qtdirs="qt" - -if test "x$ac_qt4" = "xyes"; then - ac_qtdirs="qt4 $ac_qtdirs" -fi -if test "x$ac_qt5" = "xyes"; then - ac_qtdirs="qt5 $ac_qtdirs" +# Check whether -std=c++11 support is necessary (4 < g++ version < 6). +AC_CACHE_CHECK([for g++ major version], [ac_cv_gxx_version_major], [ + ac_cv_gxx_version_major=$($CC -dumpversion) + if test -n "$ac_cv_gxx_version_major"; then + ac_cv_gxx_version_major=$(echo $ac_cv_gxx_version_major | cut -d'.' -f1); + fi + ac_gxx_version_major=$(($ac_cv_gxx_version_major + 0)) +]) +ac_gxx_version_major=$ac_cv_gxx_version_major +if test $ac_gxx_version_major -gt 4 -a $ac_gxx_version_major -lt 6; then + CXXFLAGS="-std=c++11 $CXXFLAGS" fi -ac_topdirs="/usr/local /usr" -ac_subdirs="lib" +# Check for proper flags. +ac_arch=$(uname -m) + +# Check for install paths and alternatives... +ac_libdirs="lib" if test "x$ac_arch" = "xx86_64"; then - ac_subdirs="$ac_subdirs lib64" -fi - -if test "x$ac_arch" = "xx86_64" -o "x$ac_qt5" = "xyes"; then - CFLAGS="-fPIC $CFLAGS" - CPPFLAGS="-fPIC $CPPFLAGS" + ac_libdirs="$ac_libdirs lib64" fi -for X in $ac_topdirs; do - for Y in share $ac_subdirs; do - for Z in $ac_qtdirs; do - if test -d $X/$Y/$Z/bin; then - ac_with_paths="$X/$Y/$Z $ac_with_paths" - fi - done - done -done +CFLAGS="-fPIC $CFLAGS" +CPPFLAGS="-fPIC $CPPFLAGS" # Prepend alternate dependencies paths. ac_path=$PATH + for X in $ac_with_paths; do if test -d $X/bin; then ac_path="$X/bin:$ac_path" fi if test -d $X/include; then - for Y in $ac_qtdirs; do - if test -d $X/include/$Y; then - CFLAGS="-I$X/include/$Y $CFLAGS" - CPPFLAGS="-I$X/include/$Y $CPPFLAGS" - ac_incpath="$X/include/$Y $ac_incpath" - fi - done - CFLAGS="$CFLAGS -I$X/include" - CPPFLAGS="$CPPFLAGS -I$X/include" - ac_incpath="$ac_incpath $X/include" + CFLAGS="-I$X/include $CFLAGS " + CPPFLAGS="-I$X/include $CPPFLAGS" + ac_incpath="$X/include $ac_incpath" fi - for Y in $ac_subdirs; do + for Y in $ac_libdirs; do if test -d $X/$Y; then - LIBS="$LIBS -L$X/$Y" - ac_libs="$ac_libs -L$X/$Y" + LIBS="-L$X/$Y $LIBS" + ac_libs="-L$X/$Y $ac_libs" fi done done -# Check for proper Qt4/5 version. +# A common error message: +ac_errmsg="not found in current PATH. Maybe QT development environment isn't available." + +if test "x$ac_qt4" = "xyes"; then + AC_PATH_PROG(ac_qmake, qmake-qt4, [no], $ac_path) +else + AC_PATH_PROG(ac_qmake, qmake-qt5, [no], $ac_path) +fi +if test "x$ac_qmake" = "xno"; then + AC_PATH_PROG(ac_cv_qmake, qmake, [no], $ac_path) + ac_qmake=$ac_cv_qmake +fi +if test "x$ac_qmake" = "xno"; then + AC_MSG_ERROR([qmake $ac_errmsg]) +fi + +# Check for proper Qt major version. +AC_CACHE_CHECK([for Qt major version], [ac_cv_qt_version_major], [ + ac_cv_qt_version_major=$($ac_qmake -query QT_VERSION | cut -d'.' -f1) + ac_cv_qt_version_major=$(($ac_cv_qt_version_major + 0)) +]) +ac_qt_version_major=$ac_cv_qt_version_major +if test "x$ac_qt4" = "xyes"; then + if test $ac_qt_version_major -ne 4; then + AC_MSG_ERROR([qmake-qt4 $ac_errmsg (qt4-devel)]) + fi +else + if test $ac_qt_version_major -ne 5; then + AC_MSG_ERROR([qmake-qt5 $ac_errmsg (qt5-devel)]) + fi +fi + +# Check for proper Qt install path. +AC_CACHE_CHECK([for Qt install path], [ac_cv_qt_install_path], [ + ac_cv_qt_install_path=$($ac_qmake -query QT_INSTALL_BINS) +]) +ac_qt_install_path=$ac_cv_qt_install_path +if test -d $ac_qt_install_path; then + ac_path="$ac_qt_install_path:$ac_path" +fi + +# Check it again, now with updated PATH, just in case... +AC_PATH_PROG(ac_cv_qmake, qmake, [no], $ac_path) +ac_qmake=$ac_cv_qmake +if test "x$ac_qmake" = "xno"; then + AC_MSG_ERROR([qmake $ac_errmsg]) +fi + +AC_SUBST(ac_qmake) + +AC_CACHE_CHECK([for Qt install headers], [ac_cv_qt_install_headers], [ + ac_cv_qt_install_headers=$($ac_qmake -query QT_INSTALL_HEADERS) +]) +ac_qt_install_headers=$ac_cv_qt_install_headers +if test -d $ac_qt_install_headers; then + CFLAGS="-I$ac_qt_install_headers $CFLAGS " + CPPFLAGS="-I$ac_qt_install_headers $CPPFLAGS" + ac_incpath="$ac_qt_install_headers $ac_incpath" +fi + +AC_CACHE_CHECK([for Qt install libraries], [ac_cv_qt_install_libs], [ + ac_cv_qt_install_libs=$($ac_qmake -query QT_INSTALL_LIBS) +]) +ac_qt_install_libs=$ac_cv_qt_install_libs +if test -d $ac_qt_install_libs; then + LIBS="-L$ac_qt_install_libs $LIBS" + ac_libs="-L$ac_qt_install_libs $ac_libs" +fi + +# Finally, check for proper Qt4/5 version. if test "x$ac_qt4" = "xyes"; then AC_CACHE_CHECK([for Qt library version >= 4.4], ac_cv_qtversion, [ - AC_TRY_LINK([#include "QtCore/qglobal.h"], [ + AC_TRY_COMPILE([#include "QtCore/qglobal.h"], [ #if QT_VERSION < 0x040400 || QT_VERSION >= 0x050000 #error Qt library 4.4 or greater required. #endif @@ -191,12 +282,10 @@ exit 1 ]) ]) -fi - -if test "x$ac_qt5" = "xyes"; then +else AC_CACHE_CHECK([for Qt library version >= 5.1], ac_cv_qtversion, [ - AC_TRY_LINK([#include "QtCore/qglobal.h"], [ + AC_TRY_COMPILE([#include "QtCore/qglobal.h"], [ #if QT_VERSION < 0x050100 || QT_VERSION >= 0x060000 #error Qt library 5.1 or greater required. #endif @@ -207,16 +296,6 @@ ]) fi -# A common error message: -ac_errmsg="not found in current PATH. Maybe QT development environment isn't available (qt-devel)." - -# Check for Qt qmake utility. -AC_PATH_PROG(ac_qmake, qmake, [no], $ac_path) -if test "x$ac_qmake" = "xno"; then - AC_MSG_ERROR([qmake $ac_errmsg]) -fi -AC_SUBST(ac_qmake) - # Check for Qt moc utility. AC_PATH_PROG(ac_moc, moc, [no], $ac_path) if test "x$ac_moc" = "xno"; then @@ -245,6 +324,7 @@ fi AC_SUBST(ac_lrelease) + # Checks for libraries. AC_CHECK_LIB(m, main) AC_CHECK_LIB(X11, main) @@ -257,16 +337,20 @@ fi # Check for mandatory libraries. -AC_CHECK_LIB(lscp, main, [ac_liblscp="yes"], [ac_liblscp="no"]) -if test "x$ac_liblscp" = "xno"; then - AC_MSG_ERROR([LSCP library not found.]) +PKG_CHECK_MODULES([LSCP], [lscp], [ac_liblscp="yes"], [ac_liblscp="no"]) +if test "x$ac_liblscp" = "xyes"; then + AC_DEFINE(CONFIG_LIBLSCP, 1, [Define if liblscp is available.]) + ac_cflags="$ac_cflags $LSCP_CFLAGS" + ac_libs="$ac_libs $LSCP_LIBS" +else + AC_MSG_ERROR([*** LSCP library not found (liblscp).]) fi -ac_libs="$ac_libs -llscp" + case "{$host}" in - *mingw*) - ac_libs="$ac_libs -lws2_32" - LIBS="$LIBS -lws2_32" - ;; + *mingw*) + ac_libs="$ac_libs -lws2_32" + LIBS="$LIBS -lws2_32" + ;; esac AC_CACHE_CHECK([for instrument_name in lscp_channel_info_t], @@ -384,16 +468,16 @@ # Check for optional libraries. if test "x$ac_libgig" = "xyes"; then - PKG_CHECK_MODULES(LIBGIG, gig >= 3.3.0, [ac_libgig="yes"], [ac_libgig="no"]) - if test "x$ac_libgig" = "xyes"; then - AC_DEFINE(CONFIG_LIBGIG, 1, [Define if libgig is available.]) - AC_SUBST(LIBGIG_CFLAGS) - AC_SUBST(LIBGIG_LIBS) - ac_cflags="$ac_cflags $LIBGIG_CFLAGS" - ac_libs="$ac_libs $LIBGIG_LIBS" - AC_DEFINE(CONFIG_LIBGIG_SETAUTOLOAD, 1, [Define if libgig provides gig::File::SetAutoLoad() method.]) - ac_libgig_setautoload="yes" - fi + PKG_CHECK_MODULES([GIG], [gig >= 3.3.0], [ac_libgig="yes"], [ac_libgig="no"]) +fi +if test "x$ac_libgig" = "xyes"; then + AC_DEFINE(CONFIG_LIBGIG, 1, [Define if libgig is available.]) + ac_cflags="$ac_cflags $GIG_CFLAGS" + ac_libs="$ac_libs $GIG_LIBS" + AC_DEFINE(CONFIG_LIBGIG_SETAUTOLOAD, 1, [Define if libgig provides gig::File::SetAutoLoad() method.]) + ac_libgig_setautoload="yes" +else + AC_MSG_WARN([*** GIG library not found (libgig).]) fi # Check for round math function. @@ -402,31 +486,12 @@ AC_DEFINE(CONFIG_ROUND, 1, [Define if round is available.]) fi -# Check for debugging stack-trace. -if test "x$ac_stacktrace" = "xyes"; then - AC_DEFINE(CONFIG_STACKTRACE, 1, [Define if debugger stack-trace is enabled.]) -fi - -# Some recent distros (eg. fedora, debian) require this. -if test "x$ac_cv_lib_X11_main" = "xyes"; then - ac_libs="$ac_libs -lX11" -fi - -AC_SUBST(ac_libs) -AC_SUBST(ac_incpath) -AC_SUBST(ac_cflags) -AC_SUBST(ac_ldflags) # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(fcntl.h sys/ioctl.h unistd.h signal.h sys/socket.h) -AC_CHECK_HEADER(lscp/client.h, [ac_lscp_h="yes"], [ac_lscp_h="no"]) -if test "x$ac_lscp_h" = "xno"; then - AC_MSG_ERROR([LSCP headers not found.]) -fi - if test "x$ac_libgig" = "xyes"; then AC_CHECK_HEADER(libgig/SF.h, [ac_libgig_sf2="yes"], [ac_libgig_sf2="no"]) if test "x$ac_libgig_sf2" = "xyes"; then @@ -434,6 +499,30 @@ fi fi +# Check for X11 unique/single instance. +if test "x$ac_xunique" = "xyes"; then + AC_DEFINE(CONFIG_XUNIQUE, 1, [Define if X11 unique/single instance is enabled.]) + if test "x$ac_qt4" = "xno"; then + ac_qx11extras="x11extras" + fi + # Some recent distros (eg. fedora, debian) require this. + if test "x$ac_cv_lib_X11_main" = "xyes"; then + ac_libs="$ac_libs -lX11" + fi +fi +AC_SUBST(ac_qx11extras) + +# Check for debugging stack-trace. +if test "x$ac_stacktrace" = "xyes"; then + AC_DEFINE(CONFIG_STACKTRACE, 1, [Define if debugger stack-trace is enabled.]) +fi + +AC_SUBST(ac_cflags) +AC_SUBST(ac_ldflags) +AC_SUBST(ac_incpath) +AC_SUBST(ac_libs) + + # Checks for typedefs, structures, and compiler characteristics. # AC_C_CONST @@ -448,7 +537,7 @@ # Output summary message echo -echo " $PACKAGE_NAME $PACKAGE_VERSION" +echo " $PACKAGE_NAME $ac_build_version ($ac_build_date)" echo echo " Build target . . . . . . . . . . . . . . . . . . .: $ac_debug" echo @@ -470,6 +559,7 @@ echo " LSCP device MIDI event support . . . . . . . . . .: $ac_device_midi_event" echo " LSCP runtime max. voices / disk streams support .: $ac_max_voices" echo +echo " X11 Unique/Single instance . . . . . . . . . . . .: $ac_xunique" echo " Debugger stack-trace (gdb) . . . . . . . . . . . .: $ac_stacktrace" echo echo " Install prefix . . . . . . . . . . . . . . . . . .: $ac_prefix"