2020-10-19 01:22:01 +03:00
AC_INIT([qbittorrent], [v4.4.0alpha], [bugs.qbittorrent.org], [], [https://www.qbittorrent.org/])
2014-04-19 23:47:08 +04:00
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
2020-12-23 10:20:51 +03:00
: ${CFLAGS=""}
: ${CXXFLAGS=""}
2014-04-19 23:47:08 +04:00
AC_PROG_CC
AC_PROG_CXX
2014-11-23 20:56:16 +03:00
AC_PROG_SED
2014-04-19 23:47:08 +04:00
AC_LANG(C++)
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE
2018-12-08 08:05:05 +03:00
# use compiler from env variables if available
QBT_CC="$CC"
QBT_CXX="$CXX"
2014-04-19 23:47:08 +04:00
# Define --wth-* and --enable-* arguments
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--enable-debug],
[Enable debug build])],
[],
[enable_debug=no])
2014-11-12 14:06:05 +03:00
2018-04-09 23:30:20 +03:00
AC_ARG_ENABLE(stacktrace,
[AS_HELP_STRING([--enable-stacktrace],
[Enable stacktrace feature (default=auto)])],
[],
[enable_stacktrace=auto])
2014-04-19 23:47:08 +04:00
AC_ARG_ENABLE(gui,
[AS_HELP_STRING([--disable-gui],
[Disable the GUI for headless running. Disables QtDBus and the GeoIP Database.])],
[],
[enable_gui=yes])
2014-11-12 14:06:05 +03:00
2015-04-05 15:12:36 +03:00
AC_ARG_ENABLE(systemd,
[AS_HELP_STRING([--enable-systemd],
2015-05-02 23:51:51 +03:00
[Install the systemd service file (headless only).])],
2015-04-05 15:12:36 +03:00
[],
[enable_systemd=no])
2015-01-18 15:13:06 +03:00
AC_ARG_ENABLE(webui,
[AS_HELP_STRING([--disable-webui],
[Disable the WebUI.])],
[],
[enable_webui=yes])
2014-04-19 23:47:08 +04:00
AC_ARG_ENABLE(qt-dbus,
[AS_HELP_STRING([--disable-qt-dbus],
[Disable use of QtDBus (GUI only)])],
[],
[enable_qt_dbus=yes])
# Detect OS
AC_MSG_CHECKING([whether OS is FreeBSD])
2015-05-11 00:25:32 +03:00
AS_IF([expr "$host_os" : ".*freebsd.*" > /dev/null],
2014-04-19 23:47:08 +04:00
[AC_MSG_RESULT([yes])
LIBS="-lexecinfo $LIBS"],
[AC_MSG_RESULT([no])])
2016-10-21 08:49:09 +03:00
AC_MSG_CHECKING([whether OS is macOS])
AS_IF([expr "$host_os" : ".*darwin.*" > /dev/null],
[AC_MSG_RESULT([yes])
enable_qt_dbus=no],
[AC_MSG_RESULT([no])])
2015-04-05 14:17:22 +03:00
# Require 0.23 pkg-config
PKG_PROG_PKG_CONFIG([0.23])
2014-11-12 14:06:05 +03:00
AS_IF([test "x$PKG_CONFIG" = "x"],
2014-04-19 23:47:08 +04:00
[AC_MSG_ERROR([Could not find pkg-config])])
# Check which arguments were set and act accordingly
AC_MSG_CHECKING([whether to enable the Debug build])
2014-11-12 14:06:05 +03:00
AS_CASE(["x$enable_debug"],
2014-04-19 23:47:08 +04:00
["xno"],
[AC_MSG_RESULT([no])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG release"
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG debug"],
["xyes"],
[AC_MSG_RESULT([yes])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG debug"
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG release"],
[AC_MSG_RESULT([$enable_debug])
AC_MSG_ERROR([Unknown option "$enable_debug". Use either "yes" or "no".])])
2014-11-12 14:06:05 +03:00
2018-04-09 23:30:20 +03:00
AC_MSG_CHECKING([whether to enable the stacktrace feature])
AS_CASE(["x$enable_stacktrace"],
["xno"],
[AC_MSG_RESULT([no])
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"],
["xyes"],
[AC_MSG_RESULT([yes])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
["xauto"],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <execinfo.h>]])],
[AC_MSG_RESULT([yes])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
[AC_MSG_RESULT([no])
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"])],
[AC_MSG_RESULT([$enable_stacktrace])
AC_MSG_ERROR([Unknown option "$enable_stacktrace". Use either "yes" or "no".])])
2014-04-19 23:47:08 +04:00
AC_MSG_CHECKING([whether to enable the GUI])
AS_CASE(["x$enable_gui"],
["xyes"],
[AC_MSG_RESULT([yes])
2015-04-05 15:12:36 +03:00
enable_systemd=[no]
2015-01-18 15:13:06 +03:00
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG nogui"],
2014-04-19 23:47:08 +04:00
["xno"],
[AC_MSG_RESULT([no])
enable_qt_dbus=[no]
2015-01-18 15:13:06 +03:00
QBT_ADD_CONFIG="$QBT_ADD_CONFIG nogui"],
2014-04-19 23:47:08 +04:00
[AC_MSG_RESULT([$enable_gui])
AC_MSG_ERROR([Unknown option "$enable_gui". Use either "yes" or "no".])])
2015-04-05 15:12:36 +03:00
AC_MSG_CHECKING([whether to install the systemd service file])
AS_CASE(["x$enable_systemd"],
["xyes"],
[AC_MSG_RESULT([yes])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG systemd"],
["xno"],
[AC_MSG_RESULT([no])
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG systemd"],
[AC_MSG_RESULT([$enable_systemd])
AC_MSG_ERROR([Unknown option "$enable_systemd". Use either "yes" or "no".])])
2015-01-18 15:13:06 +03:00
AC_MSG_CHECKING([whether to enable the WebUI])
AS_CASE(["x$enable_webui"],
["xyes"],
[AC_MSG_RESULT([yes])
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG nowebui"],
["xno"],
[AC_MSG_RESULT([no])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG nowebui"],
[AC_MSG_RESULT([$enable_webui])
AC_MSG_ERROR([Unknown option "$enable_webui". Use either "yes" or "no".])])
2017-01-19 15:10:09 +03:00
FIND_QT5()
2017-08-13 20:29:53 +03:00
AS_IF([test "x$QT_QMAKE" = "x"],
[AC_MSG_ERROR([Could not find qmake])
])
2017-08-18 23:00:53 +03:00
AS_IF([test "x$enable_gui" = "xyes"],
2021-02-18 11:51:00 +03:00
[PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.12])
2017-11-17 10:39:02 +03:00
])
2014-04-19 23:47:08 +04:00
AC_MSG_CHECKING([whether QtDBus should be enabled])
AS_CASE(["x$enable_qt_dbus"],
["xyes"],
[AC_MSG_RESULT([yes])
FIND_QTDBUS()
2014-11-12 14:06:05 +03:00
AS_IF([test "x$HAVE_QTDBUS" = "xfalse"],
2014-04-19 23:47:08 +04:00
[AC_MSG_ERROR([Could not find QtDBus])],
[QBT_ADD_CONFIG="$QBT_ADD_CONFIG dbus"]
)],
["xno"],
[AC_MSG_RESULT([no])
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG dbus"],
[AC_MSG_RESULT([$enable_qt_dbus])
AC_MSG_ERROR([Unknown option "$enable_qt_dbus". Use either "yes" or "no".])])
2014-11-12 14:06:05 +03:00
2020-12-04 15:16:04 +03:00
AX_BOOST_BASE([1.65],
2018-11-28 20:57:28 +03:00
[AC_MSG_NOTICE([Boost CXXFLAGS: "$BOOST_CPPFLAGS"])
2018-11-24 02:24:08 +03:00
AC_MSG_NOTICE([Boost LDFLAGS: "$BOOST_LDFLAGS"])],
2017-11-17 10:39:02 +03:00
[AC_MSG_ERROR([Could not find Boost])])
2018-11-28 20:57:28 +03:00
CXXFLAGS="$BOOST_CPPFLAGS $CXXFLAGS"
2017-11-17 10:39:02 +03:00
LDFLAGS="$BOOST_LDFLAGS $LDFLAGS"
2014-04-19 23:47:08 +04:00
2018-05-31 19:31:16 +03:00
# add workaround for problematic boost version
# taken from ax_boost_base.m4
m4_define([DETECT_BOOST_VERSION_PROGRAM],
[AC_LANG_PROGRAM([[#include <boost/version.hpp>]],
[[(void) ((void)sizeof(char[1 - 2*!!((BOOST_VERSION) < ($1))]));]])])
AC_COMPILE_IFELSE([DETECT_BOOST_VERSION_PROGRAM(106000)], [],
[QBT_ADD_DEFINES="$QBT_ADD_DEFINES BOOST_NO_CXX11_RVALUE_REFERENCES"])
2014-04-19 23:47:08 +04:00
AX_BOOST_SYSTEM()
2017-11-17 10:39:02 +03:00
AC_MSG_NOTICE([Boost.System LIB: "$BOOST_SYSTEM_LIB"])
LIBS="$BOOST_SYSTEM_LIB $LIBS"
2014-04-19 23:47:08 +04:00
2015-07-25 15:40:15 +03:00
PKG_CHECK_MODULES(libtorrent,
2021-01-09 22:53:36 +03:00
[libtorrent-rasterbar >= 1.2.12],
2018-11-28 20:57:28 +03:00
[CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS"
2015-07-25 15:40:15 +03:00
LIBS="$libtorrent_LIBS $LIBS"])
2018-11-21 16:29:10 +03:00
PKG_CHECK_MODULES(openssl,
2020-12-04 15:16:04 +03:00
[openssl >= 1.1.1],
2018-11-21 16:29:10 +03:00
[CXXFLAGS="$openssl_CFLAGS $CXXFLAGS"
LIBS="$openssl_LIBS $LIBS"])
2014-04-19 23:47:08 +04:00
PKG_CHECK_MODULES(zlib,
2020-12-04 15:16:04 +03:00
[zlib >= 1.2.11],
2018-11-28 20:57:28 +03:00
[CXXFLAGS="$zlib_CFLAGS $CXXFLAGS"
2014-04-19 23:47:08 +04:00
LIBS="$zlib_LIBS $LIBS"])
2020-12-19 09:52:01 +03:00
# Check if already in >= C++17 mode because of the flags returned by one of the above packages
2019-03-24 09:53:20 +03:00
TMP_CXXFLAGS="$CXXFLAGS"
CXXFLAGS=""
2020-12-19 09:52:01 +03:00
AC_MSG_CHECKING([if compiler defaults to C++17 or later mode])
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
2018-11-24 01:12:38 +03:00
[AC_MSG_RESULT([yes])
2020-12-19 09:52:01 +03:00
QBT_CXX17_FOUND="yes"],
2018-11-24 01:12:38 +03:00
[AC_MSG_RESULT([no])
2020-12-19 09:52:01 +03:00
QBT_CXX17_FOUND="no"])
2018-11-21 16:29:10 +03:00
2020-12-19 09:52:01 +03:00
# In case of no, check if the compiler can support at least C++17
2018-11-24 01:12:38 +03:00
# and if yes, enable it leaving a warning to the user
2020-12-19 09:52:01 +03:00
AS_IF([test "x$QBT_CXX17_FOUND" = "xno"],
[AC_MSG_CHECKING([if compiler supports C++17])
CXXFLAGS="-std=c++17"
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
2018-11-24 01:12:38 +03:00
[AC_MSG_RESULT([yes])
2020-12-19 09:52:01 +03:00
AC_MSG_CHECKING([if C++17 is disabled by the set compiler flags])
2018-11-24 01:12:38 +03:00
# prepend the flag so it won't override conflicting user defined flags
2020-12-19 09:52:01 +03:00
CXXFLAGS="-std=c++17 $TMP_CXXFLAGS"
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
2018-11-24 01:12:38 +03:00
[AC_MSG_RESULT([no])
2020-12-19 09:52:01 +03:00
QBT_ADD_CONFIG="$QBT_ADD_CONFIG c++17"
AC_MSG_WARN([C++17 mode is now force enabled. The C++ mode should match the mode that other libraries were built with, otherwise you'll likely get linking errors.])],
2018-11-24 01:12:38 +03:00
[AC_MSG_RESULT([yes])
2020-12-19 09:52:01 +03:00
AC_MSG_ERROR([The compiler supports C++17 but the user or a dependency has explicitly enabled a lower mode.])])],
2018-11-24 01:12:38 +03:00
[AC_MSG_RESULT([no])
2020-12-19 09:52:01 +03:00
AC_MSG_ERROR([A compiler supporting C++17 is required.])])
2018-11-24 01:12:38 +03:00
])
2019-03-24 09:53:20 +03:00
CXXFLAGS="$TMP_CXXFLAGS"
2018-11-07 19:14:10 +03:00
2014-04-19 23:47:08 +04:00
# These are required because autoconf doesn't expand these **particular**
2014-11-12 14:06:05 +03:00
# vars automatically. And qmake cannot autoexpand them.
2014-04-19 23:47:08 +04:00
AX_DEFINE_DIR([EXPAND_PREFIX], [prefix])
AX_DEFINE_DIR([EXPAND_BINDIR], [bindir])
AX_DEFINE_DIR([EXPAND_DATADIR], [datadir])
AX_DEFINE_DIR([EXPAND_MANDIR], [mandir])
2014-11-20 18:47:31 +03:00
# Original extract() function contributed by pmzqla
# $*: Strings to parse
2015-05-11 14:48:13 +03:00
# Set $QBT_CONF_DEFINES, $QBT_CONF_INCLUDES, $QBT_CONF_EXTRA_CFLAGS
2014-11-20 18:47:31 +03:00
extract() {
if [[ -z "$*" ]]; then
echo "Input string required"
return 1
fi
2015-08-06 23:08:11 +03:00
# BSD sed needs an actual newline character in the substitute command
new_line='
'
2015-05-11 14:48:13 +03:00
# Convert " -" to "\n" if not between quotes and remove possible leading white spaces
2018-01-02 18:33:07 +03:00
string=$(echo " $*" | $SED -e "s: -:\\${new_line}:g" -e 's:"\(.*\)\n\(.*\)":\"\1 -\2":g' -e "s:'\(.*\)\n\(.*\)':\'\1 -\2':g" -e 's/^[[[:space:]]]*//')
2014-11-20 18:47:31 +03:00
SAVEIFS=$IFS
IFS=$(printf "\n\b")
for i in $string; do
case "$(echo "$i" | cut -c1)" in
'') ;;
2018-11-24 01:12:38 +03:00
D) QBT_CONF_DEFINES="$QBT_CONF_DEFINES $(echo $i | cut -c2-)";;
I) QBT_CONF_INCLUDES="$QBT_CONF_INCLUDES $(echo $i | cut -c2-)";;
*) QBT_CONF_EXTRA_CFLAGS="$QBT_CONF_EXTRA_CFLAGS -$i";;
2014-11-20 18:47:31 +03:00
esac
done
IFS=$SAVEIFS
}
2018-11-28 20:57:28 +03:00
extract "$CFLAGS $CXXFLAGS"
2014-11-20 18:47:31 +03:00
QBT_ADD_DEFINES="$QBT_ADD_DEFINES $QBT_CONF_DEFINES"
2014-04-19 23:47:08 +04:00
# Substitute the values of these vars in conf.pri.in
2018-12-08 08:05:05 +03:00
AC_SUBST(QBT_CC)
AC_SUBST(QBT_CXX)
2014-11-20 18:47:31 +03:00
AC_SUBST(QBT_CONF_INCLUDES)
AC_SUBST(QBT_CONF_EXTRA_CFLAGS)
2014-04-19 23:47:08 +04:00
AC_SUBST(QBT_ADD_CONFIG)
AC_SUBST(QBT_REMOVE_CONFIG)
AC_SUBST(QBT_ADD_DEFINES)
AC_SUBST(QBT_REMOVE_DEFINES)
2020-12-29 19:54:41 +03:00
QBT_CONFIG_FILES="conf.pri"
2015-05-02 23:38:40 +03:00
AS_IF([test "x$enable_systemd" = "xyes"],
2020-12-29 19:54:41 +03:00
[QBT_CONFIG_FILES="$QBT_CONFIG_FILES dist/unix/systemd/qbittorrent-nox@.service"])
AC_CONFIG_FILES(["$QBT_CONFIG_FILES"])
AC_OUTPUT
2014-04-19 23:47:08 +04:00
AC_MSG_NOTICE([Running qmake to generate the makefile...])
2018-12-21 13:31:49 +03:00
TOPDIR="$(cd "$(dirname "$0")" && pwd)"
$QT_QMAKE -r "$TOPDIR/qbittorrent.pro" "QMAKE_LRELEASE=$QMAKE_LRELEASE"
qmake_ret="$?"
2014-04-19 23:47:08 +04:00
AS_ECHO()
2018-12-21 13:31:49 +03:00
AS_IF([test "x$qmake_ret" != "x0"],
[AC_MSG_ERROR([$QT_QMAKE failed to generate the makefile])])
AC_MSG_NOTICE([Good, the configure finished.])
2014-04-19 23:47:08 +04:00
AS_ECHO()