Bump to 4.1.2
[qBittorrent.git] / configure.ac
blob0d0f76dc0dc2fcfbcf17a6956c0a44c7fe95d46e
1 AC_INIT([qbittorrent], [v4.1.2], [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
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)])],
18             [],
19             [with_qtsingleapplication=shipped])
21 AC_ARG_ENABLE(debug,
22               [AS_HELP_STRING([--enable-debug],
23                               [Enable debug build])],
24               [],
25               [enable_debug=no])
27 AC_ARG_ENABLE(stacktrace,
28               [AS_HELP_STRING([--enable-stacktrace],
29                               [Enable stacktrace feature (default=auto)])],
30               [],
31               [enable_stacktrace=auto])
33 AC_ARG_ENABLE(gui,
34               [AS_HELP_STRING([--disable-gui],
35                               [Disable the GUI for headless running. Disables QtDBus and the GeoIP Database.])],
36               [],
37               [enable_gui=yes])
39 AC_ARG_ENABLE(systemd,
40               [AS_HELP_STRING([--enable-systemd],
41                               [Install the systemd service file (headless only).])],
42               [],
43               [enable_systemd=no])
45 AC_ARG_ENABLE(webui,
46               [AS_HELP_STRING([--disable-webui],
47                               [Disable the WebUI.])],
48               [],
49               [enable_webui=yes])
51 AC_ARG_ENABLE(qt-dbus,
52               [AS_HELP_STRING([--disable-qt-dbus],
53                               [Disable use of QtDBus (GUI only)])],
54               [],
55               [enable_qt_dbus=yes])
57 # Detect OS
58 AC_MSG_CHECKING([whether OS is FreeBSD])
59 AS_IF([expr "$host_os" : ".*freebsd.*" > /dev/null],
60       [AC_MSG_RESULT([yes])
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],
66       [AC_MSG_RESULT([yes])
67       enable_qt_dbus=no],
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"],
78         ["xno"],
79               [AC_MSG_RESULT([no])
80               QBT_ADD_CONFIG="$QBT_ADD_CONFIG release"
81               QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG debug"],
82         ["xyes"],
83                [AC_MSG_RESULT([yes])
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"],
91         ["xno"],
92               [AC_MSG_RESULT([no])
93               QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"],
94         ["xyes"],
95                [AC_MSG_RESULT([yes])
96                QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
97         ["xauto"],
98                 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <execinfo.h>]])],
99                 [AC_MSG_RESULT([yes])
100                 QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
101                 [AC_MSG_RESULT([no])
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"],
108         ["xyes"],
109                [AC_MSG_RESULT([yes])
110                enable_systemd=[no]
111                QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG nogui"],
112         ["xno"],
113               [AC_MSG_RESULT([no])
114               enable_qt_dbus=[no]
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"],
121         ["xyes"],
122                [AC_MSG_RESULT([yes])
123                QBT_ADD_CONFIG="$QBT_ADD_CONFIG systemd"],
124         ["xno"],
125               [AC_MSG_RESULT([no])
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"],
132         ["xyes"],
133                [AC_MSG_RESULT([yes])
134                QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG nowebui"],
135         ["xno"],
136               [AC_MSG_RESULT([no])
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".])])
141 FIND_QT5()
142 AS_IF([test "x$QT_QMAKE" = "x"],
143       [AC_MSG_ERROR([Could not find qmake])
144       ])
145 AS_IF([test "x$enable_gui" = "xyes"],
146       [PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.5.1])
147       ])
148 AC_MSG_CHECKING([whether QtDBus should be enabled])
149 AS_CASE(["x$enable_qt_dbus"],
150         ["xyes"],
151                [AC_MSG_RESULT([yes])
152                FIND_QTDBUS()
153                AS_IF([test "x$HAVE_QTDBUS" = "xfalse"],
154                      [AC_MSG_ERROR([Could not find QtDBus])],
155                      [QBT_ADD_CONFIG="$QBT_ADD_CONFIG dbus"]
156                     )],
157         ["xno"],
158               [AC_MSG_RESULT([no])
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
172 AC_LANG_PUSH(C++)
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"])
180 AC_LANG_POP([C++])
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.0.6],
199                   [CPPFLAGS="$libtorrent_CFLAGS $CPPFLAGS"
200                   LIBS="$libtorrent_LIBS $LIBS"])
202 PKG_CHECK_MODULES(zlib,
203                  [zlib >= 1.2.5.2],
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
217 extract() {
218   if [[ -z "$*" ]]; then
219     echo "Input string required"
220     return 1
221   fi
223   # BSD sed needs an actual newline character in the substitute command
224   new_line='
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:]]]*//')
228   SAVEIFS=$IFS
229   IFS=$(printf "\n\b")
230   for i in $string; do
231     case "$(echo "$i" | cut -c1)" in
232       '') ;;
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";;
236     esac
237   done
238   IFS=$SAVEIFS
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)
252 AC_OUTPUT(conf.pri)
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"
263 ret="$?"
265 AS_ECHO()
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])])
269 AS_ECHO()