Replace CheckBox with Arrow in transferlistfilterswidget.cpp
[qBittorrent.git] / configure.ac
blobffd046f6d651828b194930b33a603f9dadfa3909
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])
4 AC_PROG_CC
5 AC_PROG_CXX
6 AC_PROG_SED
7 AC_LANG(C++)
8 AC_CANONICAL_HOST
9 AM_INIT_AUTOMAKE
11 # use compiler from env variables if available
12 QBT_CC="$CC"
13 QBT_CXX="$CXX"
15 # Define --wth-* and --enable-* arguments
17 AC_ARG_WITH(qtsingleapplication,
18             [AS_HELP_STRING([--with-qtsingleapplication=@<:@system|shipped@:>@],
19                             [Use the shipped qtsingleapplication library or the system one (default=shipped)])],
20             [],
21             [with_qtsingleapplication=shipped])
23 AC_ARG_ENABLE(debug,
24               [AS_HELP_STRING([--enable-debug],
25                               [Enable debug build])],
26               [],
27               [enable_debug=no])
29 AC_ARG_ENABLE(stacktrace,
30               [AS_HELP_STRING([--enable-stacktrace],
31                               [Enable stacktrace feature (default=auto)])],
32               [],
33               [enable_stacktrace=auto])
35 AC_ARG_ENABLE(gui,
36               [AS_HELP_STRING([--disable-gui],
37                               [Disable the GUI for headless running. Disables QtDBus and the GeoIP Database.])],
38               [],
39               [enable_gui=yes])
41 AC_ARG_ENABLE(systemd,
42               [AS_HELP_STRING([--enable-systemd],
43                               [Install the systemd service file (headless only).])],
44               [],
45               [enable_systemd=no])
47 AC_ARG_ENABLE(webui,
48               [AS_HELP_STRING([--disable-webui],
49                               [Disable the WebUI.])],
50               [],
51               [enable_webui=yes])
53 AC_ARG_ENABLE(qt-dbus,
54               [AS_HELP_STRING([--disable-qt-dbus],
55                               [Disable use of QtDBus (GUI only)])],
56               [],
57               [enable_qt_dbus=yes])
59 # Detect OS
60 AC_MSG_CHECKING([whether OS is FreeBSD])
61 AS_IF([expr "$host_os" : ".*freebsd.*" > /dev/null],
62       [AC_MSG_RESULT([yes])
63       LIBS="-lexecinfo $LIBS"],
64       [AC_MSG_RESULT([no])])
66 AC_MSG_CHECKING([whether OS is macOS])
67 AS_IF([expr "$host_os" : ".*darwin.*" > /dev/null],
68       [AC_MSG_RESULT([yes])
69       enable_qt_dbus=no],
70       [AC_MSG_RESULT([no])])
72 # Require 0.23 pkg-config
73 PKG_PROG_PKG_CONFIG([0.23])
74 AS_IF([test "x$PKG_CONFIG" = "x"],
75       [AC_MSG_ERROR([Could not find pkg-config])])
77 # Check which arguments were set and act accordingly
78 AC_MSG_CHECKING([whether to enable the Debug build])
79 AS_CASE(["x$enable_debug"],
80         ["xno"],
81               [AC_MSG_RESULT([no])
82               QBT_ADD_CONFIG="$QBT_ADD_CONFIG release"
83               QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG debug"],
84         ["xyes"],
85                [AC_MSG_RESULT([yes])
86                QBT_ADD_CONFIG="$QBT_ADD_CONFIG debug"
87                QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG release"],
88         [AC_MSG_RESULT([$enable_debug])
89         AC_MSG_ERROR([Unknown option "$enable_debug". Use either "yes" or "no".])])
91 AC_MSG_CHECKING([whether to enable the stacktrace feature])
92 AS_CASE(["x$enable_stacktrace"],
93         ["xno"],
94               [AC_MSG_RESULT([no])
95               QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"],
96         ["xyes"],
97                [AC_MSG_RESULT([yes])
98                QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
99         ["xauto"],
100                 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <execinfo.h>]])],
101                 [AC_MSG_RESULT([yes])
102                 QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
103                 [AC_MSG_RESULT([no])
104                 QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"])],
105         [AC_MSG_RESULT([$enable_stacktrace])
106         AC_MSG_ERROR([Unknown option "$enable_stacktrace". Use either "yes" or "no".])])
108 AC_MSG_CHECKING([whether to enable the GUI])
109 AS_CASE(["x$enable_gui"],
110         ["xyes"],
111                [AC_MSG_RESULT([yes])
112                enable_systemd=[no]
113                QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG nogui"],
114         ["xno"],
115               [AC_MSG_RESULT([no])
116               enable_qt_dbus=[no]
117               QBT_ADD_CONFIG="$QBT_ADD_CONFIG nogui"],
118         [AC_MSG_RESULT([$enable_gui])
119         AC_MSG_ERROR([Unknown option "$enable_gui". Use either "yes" or "no".])])
121 AC_MSG_CHECKING([whether to install the systemd service file])
122 AS_CASE(["x$enable_systemd"],
123         ["xyes"],
124                [AC_MSG_RESULT([yes])
125                QBT_ADD_CONFIG="$QBT_ADD_CONFIG systemd"],
126         ["xno"],
127               [AC_MSG_RESULT([no])
128               QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG systemd"],
129         [AC_MSG_RESULT([$enable_systemd])
130         AC_MSG_ERROR([Unknown option "$enable_systemd". Use either "yes" or "no".])])
132 AC_MSG_CHECKING([whether to enable the WebUI])
133 AS_CASE(["x$enable_webui"],
134         ["xyes"],
135                [AC_MSG_RESULT([yes])
136                QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG nowebui"],
137         ["xno"],
138               [AC_MSG_RESULT([no])
139               QBT_ADD_CONFIG="$QBT_ADD_CONFIG nowebui"],
140         [AC_MSG_RESULT([$enable_webui])
141         AC_MSG_ERROR([Unknown option "$enable_webui". Use either "yes" or "no".])])
143 FIND_QT5()
144 AS_IF([test "x$QT_QMAKE" = "x"],
145       [AC_MSG_ERROR([Could not find qmake])
146       ])
147 AS_IF([test "x$enable_gui" = "xyes"],
148       [PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.5.1])
149       ])
150 AC_MSG_CHECKING([whether QtDBus should be enabled])
151 AS_CASE(["x$enable_qt_dbus"],
152         ["xyes"],
153                [AC_MSG_RESULT([yes])
154                FIND_QTDBUS()
155                AS_IF([test "x$HAVE_QTDBUS" = "xfalse"],
156                      [AC_MSG_ERROR([Could not find QtDBus])],
157                      [QBT_ADD_CONFIG="$QBT_ADD_CONFIG dbus"]
158                     )],
159         ["xno"],
160               [AC_MSG_RESULT([no])
161               QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG dbus"],
162         [AC_MSG_RESULT([$enable_qt_dbus])
163         AC_MSG_ERROR([Unknown option "$enable_qt_dbus". Use either "yes" or "no".])])
166 AX_BOOST_BASE([1.35],
167               [AC_MSG_NOTICE([Boost CXXFLAGS: "$BOOST_CPPFLAGS"])
168                AC_MSG_NOTICE([Boost LDFLAGS: "$BOOST_LDFLAGS"])],
169               [AC_MSG_ERROR([Could not find Boost])])
170 CXXFLAGS="$BOOST_CPPFLAGS $CXXFLAGS"
171 LDFLAGS="$BOOST_LDFLAGS $LDFLAGS"
173 # add workaround for problematic boost version
174 # taken from ax_boost_base.m4
175 m4_define([DETECT_BOOST_VERSION_PROGRAM],
176     [AC_LANG_PROGRAM([[#include <boost/version.hpp>]],
177                      [[(void) ((void)sizeof(char[1 - 2*!!((BOOST_VERSION) < ($1))]));]])])
179 AC_COMPILE_IFELSE([DETECT_BOOST_VERSION_PROGRAM(106000)], [],
180     [QBT_ADD_DEFINES="$QBT_ADD_DEFINES BOOST_NO_CXX11_RVALUE_REFERENCES"])
182 AX_BOOST_SYSTEM()
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"],
188         ["xshipped"],
189                    [AC_MSG_RESULT([shipped])
190                    QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG usesystemqtsingleapplication"],
191         ["xsystem"],
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.1.10],
199                   [CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS"
200                   LIBS="$libtorrent_LIBS $LIBS"])
202 PKG_CHECK_MODULES(openssl,
203                   [openssl >= 1.0],
204                   [CXXFLAGS="$openssl_CFLAGS $CXXFLAGS"
205                   LIBS="$openssl_LIBS $LIBS"])
207 PKG_CHECK_MODULES(zlib,
208                  [zlib >= 1.2.5.2],
209                  [CXXFLAGS="$zlib_CFLAGS $CXXFLAGS"
210                  LIBS="$zlib_LIBS $LIBS"])
212 # Check if already in >= C++14 mode because of the flags returned by one of the above packages
213 TMP_CXXFLAGS="$CXXFLAGS"
214 CXXFLAGS=""
215 AC_MSG_CHECKING([if compiler defaults to C++14 or later mode])
216 AC_COMPILE_IFELSE([DETECT_CPP14_PROGRAM()],
217                   [AC_MSG_RESULT([yes])
218                    QBT_CXX14_FOUND="yes"],
219                   [AC_MSG_RESULT([no])
220                    QBT_CXX14_FOUND="no"])
222 # In case of no, check if the compiler can support at least C++14
223 # and if yes, enable it leaving a warning to the user
224 AS_IF([test "x$QBT_CXX14_FOUND" = "xno"],
225       [AC_MSG_CHECKING([if compiler supports C++14])
226        CXXFLAGS="-std=c++14"
227        AC_COMPILE_IFELSE([DETECT_CPP14_PROGRAM()],
228                         [AC_MSG_RESULT([yes])
229                          AC_MSG_CHECKING([if C++14 is disabled by the set compiler flags])
230                          # prepend the flag so it won't override conflicting user defined flags
231                          CXXFLAGS="-std=c++14 $TMP_CXXFLAGS"
232                          AC_COMPILE_IFELSE([DETECT_CPP14_PROGRAM()],
233                                            [AC_MSG_RESULT([no])
234                                             QBT_ADD_CONFIG="$QBT_ADD_CONFIG c++14"
235                                             AC_MSG_WARN([C++14 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.])],
236                                            [AC_MSG_RESULT([yes])
237                                             AC_MSG_ERROR([The compiler supports C++14 but the user or a dependency has explicitly enabled a lower mode.])])],
238                         [AC_MSG_RESULT([no])
239                          AC_MSG_ERROR([A compiler supporting C++14 is required.])])
240       ])
241 CXXFLAGS="$TMP_CXXFLAGS"
243 # These are required because autoconf doesn't expand these **particular**
244 # vars automatically. And qmake cannot autoexpand them.
245 AX_DEFINE_DIR([EXPAND_PREFIX], [prefix])
246 AX_DEFINE_DIR([EXPAND_BINDIR], [bindir])
247 AX_DEFINE_DIR([EXPAND_DATADIR], [datadir])
248 AX_DEFINE_DIR([EXPAND_MANDIR], [mandir])
250 # Original extract() function contributed by pmzqla
251 # $*: Strings to parse
252 # Set $QBT_CONF_DEFINES, $QBT_CONF_INCLUDES, $QBT_CONF_EXTRA_CFLAGS
253 extract() {
254   if [[ -z "$*" ]]; then
255     echo "Input string required"
256     return 1
257   fi
259   # BSD sed needs an actual newline character in the substitute command
260   new_line='
262   # Convert " -" to "\n" if not between quotes and remove possible leading white spaces
263   string=$(echo " $*" | $SED -e "s: -:\\${new_line}:g" -e 's:"\(.*\)\n\(.*\)":\"\1 -\2":g' -e "s:'\(.*\)\n\(.*\)':\'\1 -\2':g" -e 's/^[[[:space:]]]*//')
264   SAVEIFS=$IFS
265   IFS=$(printf "\n\b")
266   for i in $string; do
267     case "$(echo "$i" | cut -c1)" in
268       '') ;;
269       D) QBT_CONF_DEFINES="$QBT_CONF_DEFINES $(echo $i | cut -c2-)";;
270       I) QBT_CONF_INCLUDES="$QBT_CONF_INCLUDES $(echo $i | cut -c2-)";;
271       *) QBT_CONF_EXTRA_CFLAGS="$QBT_CONF_EXTRA_CFLAGS -$i";;
272     esac
273   done
274   IFS=$SAVEIFS
277 extract "$CFLAGS $CXXFLAGS"
278 QBT_ADD_DEFINES="$QBT_ADD_DEFINES $QBT_CONF_DEFINES"
280 # Substitute the values of these vars in conf.pri.in
281 AC_SUBST(QBT_CC)
282 AC_SUBST(QBT_CXX)
283 AC_SUBST(QBT_CONF_INCLUDES)
284 AC_SUBST(QBT_CONF_EXTRA_CFLAGS)
285 AC_SUBST(QBT_ADD_CONFIG)
286 AC_SUBST(QBT_REMOVE_CONFIG)
287 AC_SUBST(QBT_ADD_DEFINES)
288 AC_SUBST(QBT_REMOVE_DEFINES)
290 AC_OUTPUT(conf.pri)
291 AS_IF([test "x$enable_systemd" = "xyes"],
292       [AC_OUTPUT(dist/unix/systemd/qbittorrent-nox@.service)])
294 AC_MSG_NOTICE([Running qmake to generate the makefile...])
295 TOPDIR="$(cd "$(dirname "$0")" && pwd)"
296 $QT_QMAKE -r "$TOPDIR/qbittorrent.pro" "QMAKE_LRELEASE=$QMAKE_LRELEASE"
297 qmake_ret="$?"
299 AS_ECHO()
300 AS_IF([test "x$qmake_ret" != "x0"],
301       [AC_MSG_ERROR([$QT_QMAKE failed to generate the makefile])])
303 AC_MSG_NOTICE([Good, the configure finished.])
304 AS_ECHO()