1 AC_INIT([qbittorrent], [v4.2.0alpha], [bugs.qbittorrent.org], [], [https://www.qbittorrent.org/])
2 AC_CONFIG_AUX_DIR([build-aux])
3 AC_CONFIG_MACRO_DIR([m4])
13 # Define --wth-* and --enable-* arguments
15 AC_ARG_WITH(qtsingleapplication,
16 [AS_HELP_STRING([--with-qtsingleapplication=@<:@system|shipped@:>@],
17 [Use the shipped qtsingleapplication library or the system one (default=shipped)])],
19 [with_qtsingleapplication=shipped])
22 [AS_HELP_STRING([--enable-debug],
23 [Enable debug build])],
27 AC_ARG_ENABLE(stacktrace,
28 [AS_HELP_STRING([--enable-stacktrace],
29 [Enable stacktrace feature (default=auto)])],
31 [enable_stacktrace=auto])
34 [AS_HELP_STRING([--disable-gui],
35 [Disable the GUI for headless running. Disables QtDBus and the GeoIP Database.])],
39 AC_ARG_ENABLE(systemd,
40 [AS_HELP_STRING([--enable-systemd],
41 [Install the systemd service file (headless only).])],
46 [AS_HELP_STRING([--disable-webui],
47 [Disable the WebUI.])],
51 AC_ARG_ENABLE(qt-dbus,
52 [AS_HELP_STRING([--disable-qt-dbus],
53 [Disable use of QtDBus (GUI only)])],
58 AC_MSG_CHECKING([whether OS is FreeBSD])
59 AS_IF([expr "$host_os" : ".*freebsd.*" > /dev/null],
61 LIBS="-lexecinfo $LIBS"],
62 [AC_MSG_RESULT([no])])
64 AC_MSG_CHECKING([whether OS is macOS])
65 AS_IF([expr "$host_os" : ".*darwin.*" > /dev/null],
68 [AC_MSG_RESULT([no])])
70 # Require 0.23 pkg-config
71 PKG_PROG_PKG_CONFIG([0.23])
72 AS_IF([test "x$PKG_CONFIG" = "x"],
73 [AC_MSG_ERROR([Could not find pkg-config])])
75 # Check which arguments were set and act accordingly
76 AC_MSG_CHECKING([whether to enable the Debug build])
77 AS_CASE(["x$enable_debug"],
80 QBT_ADD_CONFIG="$QBT_ADD_CONFIG release"
81 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG debug"],
84 QBT_ADD_CONFIG="$QBT_ADD_CONFIG debug"
85 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG release"],
86 [AC_MSG_RESULT([$enable_debug])
87 AC_MSG_ERROR([Unknown option "$enable_debug". Use either "yes" or "no".])])
89 AC_MSG_CHECKING([whether to enable the stacktrace feature])
90 AS_CASE(["x$enable_stacktrace"],
93 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"],
96 QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
98 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <execinfo.h>]])],
100 QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
102 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"])],
103 [AC_MSG_RESULT([$enable_stacktrace])
104 AC_MSG_ERROR([Unknown option "$enable_stacktrace". Use either "yes" or "no".])])
106 AC_MSG_CHECKING([whether to enable the GUI])
107 AS_CASE(["x$enable_gui"],
109 [AC_MSG_RESULT([yes])
111 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG nogui"],
115 QBT_ADD_CONFIG="$QBT_ADD_CONFIG nogui"],
116 [AC_MSG_RESULT([$enable_gui])
117 AC_MSG_ERROR([Unknown option "$enable_gui". Use either "yes" or "no".])])
119 AC_MSG_CHECKING([whether to install the systemd service file])
120 AS_CASE(["x$enable_systemd"],
122 [AC_MSG_RESULT([yes])
123 QBT_ADD_CONFIG="$QBT_ADD_CONFIG systemd"],
126 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG systemd"],
127 [AC_MSG_RESULT([$enable_systemd])
128 AC_MSG_ERROR([Unknown option "$enable_systemd". Use either "yes" or "no".])])
130 AC_MSG_CHECKING([whether to enable the WebUI])
131 AS_CASE(["x$enable_webui"],
133 [AC_MSG_RESULT([yes])
134 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG nowebui"],
137 QBT_ADD_CONFIG="$QBT_ADD_CONFIG nowebui"],
138 [AC_MSG_RESULT([$enable_webui])
139 AC_MSG_ERROR([Unknown option "$enable_webui". Use either "yes" or "no".])])
142 AS_IF([test "x$QT_QMAKE" = "x"],
143 [AC_MSG_ERROR([Could not find qmake])
145 AS_IF([test "x$enable_gui" = "xyes"],
146 [PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.5.1])
148 AC_MSG_CHECKING([whether QtDBus should be enabled])
149 AS_CASE(["x$enable_qt_dbus"],
151 [AC_MSG_RESULT([yes])
153 AS_IF([test "x$HAVE_QTDBUS" = "xfalse"],
154 [AC_MSG_ERROR([Could not find QtDBus])],
155 [QBT_ADD_CONFIG="$QBT_ADD_CONFIG dbus"]
159 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG dbus"],
160 [AC_MSG_RESULT([$enable_qt_dbus])
161 AC_MSG_ERROR([Unknown option "$enable_qt_dbus". Use either "yes" or "no".])])
164 AX_BOOST_BASE([1.35],
165 [AC_MSG_NOTICE([Boost CPPFLAGS: "$BOOST_CPPFLAGS"
166 Boost LDFLAGS: "$BOOST_LDFLAGS"])],
167 [AC_MSG_ERROR([Could not find Boost])])
168 CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
169 LDFLAGS="$BOOST_LDFLAGS $LDFLAGS"
171 # add workaround for problematic boost version
173 # taken from ax_boost_base.m4
174 m4_define([DETECT_BOOST_VERSION_PROGRAM],
175 [AC_LANG_PROGRAM([[#include <boost/version.hpp>]],
176 [[(void) ((void)sizeof(char[1 - 2*!!((BOOST_VERSION) < ($1))]));]])])
178 AC_COMPILE_IFELSE([DETECT_BOOST_VERSION_PROGRAM(106000)], [],
179 [QBT_ADD_DEFINES="$QBT_ADD_DEFINES BOOST_NO_CXX11_RVALUE_REFERENCES"])
183 AC_MSG_NOTICE([Boost.System LIB: "$BOOST_SYSTEM_LIB"])
184 LIBS="$BOOST_SYSTEM_LIB $LIBS"
186 AC_MSG_CHECKING([which qtsingleapplication to use])
187 AS_CASE(["x$with_qtsingleapplication"],
189 [AC_MSG_RESULT([shipped])
190 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG usesystemqtsingleapplication"],
192 [AC_MSG_RESULT([system])
193 QBT_ADD_CONFIG="$QBT_ADD_CONFIG usesystemqtsingleapplication"],
194 [AC_MSG_RESULT([$with_qtsingleapplication])
195 AC_MSG_ERROR([Unknown option "$with_qtsingleapplication". Use either "system" or "shipped".])])
197 PKG_CHECK_MODULES(libtorrent,
198 [libtorrent-rasterbar >= 1.0.6],
199 [CPPFLAGS="$libtorrent_CFLAGS $CPPFLAGS"
200 LIBS="$libtorrent_LIBS $LIBS"])
202 PKG_CHECK_MODULES(zlib,
204 [CPPFLAGS="$zlib_CFLAGS $CPPFLAGS"
205 LIBS="$zlib_LIBS $LIBS"])
207 # These are required because autoconf doesn't expand these **particular**
208 # vars automatically. And qmake cannot autoexpand them.
209 AX_DEFINE_DIR([EXPAND_PREFIX], [prefix])
210 AX_DEFINE_DIR([EXPAND_BINDIR], [bindir])
211 AX_DEFINE_DIR([EXPAND_DATADIR], [datadir])
212 AX_DEFINE_DIR([EXPAND_MANDIR], [mandir])
214 # Original extract() function contributed by pmzqla
215 # $*: Strings to parse
216 # Set $QBT_CONF_DEFINES, $QBT_CONF_INCLUDES, $QBT_CONF_EXTRA_CFLAGS
218 if [[ -z "$*" ]]; then
219 echo "Input string required"
223 # BSD sed needs an actual newline character in the substitute command
226 # Convert " -" to "\n" if not between quotes and remove possible leading white spaces
227 string=$(echo " $*" | $SED -e "s: -:\\${new_line}:g" -e 's:"\(.*\)\n\(.*\)":\"\1 -\2":g' -e "s:'\(.*\)\n\(.*\)':\'\1 -\2':g" -e 's/^[[[:space:]]]*//')
231 case "$(echo "$i" | cut -c1)" in
233 D) QBT_CONF_DEFINES="$(echo $i | cut -c2-) $QBT_CONF_DEFINES";;
234 I) QBT_CONF_INCLUDES="$(echo $i | cut -c2-) $QBT_CONF_INCLUDES";;
235 *) QBT_CONF_EXTRA_CFLAGS="-$i $QBT_CONF_EXTRA_CFLAGS";;
241 extract "$CFLAGS $CPPFLAGS $CXXFLAGS"
242 QBT_ADD_DEFINES="$QBT_ADD_DEFINES $QBT_CONF_DEFINES"
244 # Substitute the values of these vars in conf.pri.in
245 AC_SUBST(QBT_CONF_INCLUDES)
246 AC_SUBST(QBT_CONF_EXTRA_CFLAGS)
247 AC_SUBST(QBT_ADD_CONFIG)
248 AC_SUBST(QBT_REMOVE_CONFIG)
249 AC_SUBST(QBT_ADD_DEFINES)
250 AC_SUBST(QBT_REMOVE_DEFINES)
253 AS_IF([test "x$enable_systemd" = "xyes"],
254 [AC_OUTPUT(dist/unix/systemd/qbittorrent-nox@.service)])
258 AC_MSG_NOTICE([Running qmake to generate the makefile...])
259 CONFDIR="$( cd "$( dirname "$0" )" && pwd )"
261 $QT_QMAKE -r [$CONFDIR]/qbittorrent.pro "QMAKE_LRELEASE=$QMAKE_LRELEASE"
266 AS_IF([test "x$ret" = "x0"],
267 [AC_MSG_NOTICE([Good, your configure finished.])],
268 [AC_MSG_ERROR([Failed running $QT_QMAKE to generate the makefile])])