Merge #11516: crypto: Add test cases covering the relevant HMAC-SHA{256,512} key...
[bitcoinplatinum.git] / build-aux / m4 / bitcoin_qt.m4
blobf83dba076fd132df578edfb1ec9f94715cb42317
1 dnl Copyright (c) 2013-2016 The Bitcoin Core developers
2 dnl Distributed under the MIT software license, see the accompanying
3 dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 dnl Helper for cases where a qt dependency is not met.
6 dnl Output: If qt version is auto, set bitcoin_enable_qt to false. Else, exit.
7 AC_DEFUN([BITCOIN_QT_FAIL],[
8   if test "x$bitcoin_qt_want_version" = "xauto" && test x$bitcoin_qt_force != xyes; then
9     if test x$bitcoin_enable_qt != xno; then
10       AC_MSG_WARN([$1; bitcoin-qt frontend will not be built])
11     fi
12     bitcoin_enable_qt=no
13     bitcoin_enable_qt_test=no
14   else
15     AC_MSG_ERROR([$1])
16   fi
19 AC_DEFUN([BITCOIN_QT_CHECK],[
20   if test "x$bitcoin_enable_qt" != "xno" && test x$bitcoin_qt_want_version != xno; then
21     true
22     $1
23   else
24     true
25     $2
26   fi
29 dnl BITCOIN_QT_PATH_PROGS([FOO], [foo foo2], [/path/to/search/first], [continue if missing])
30 dnl Helper for finding the path of programs needed for Qt.
31 dnl Inputs: $1: Variable to be set
32 dnl Inputs: $2: List of programs to search for
33 dnl Inputs: $3: Look for $2 here before $PATH
34 dnl Inputs: $4: If "yes", don't fail if $2 is not found.
35 dnl Output: $1 is set to the path of $2 if found. $2 are searched in order.
36 AC_DEFUN([BITCOIN_QT_PATH_PROGS],[
37   BITCOIN_QT_CHECK([
38     if test "x$3" != "x"; then
39       AC_PATH_PROGS($1,$2,,$3)
40     else
41       AC_PATH_PROGS($1,$2)
42     fi
43     if test "x$$1" = "x" && test "x$4" != "xyes"; then
44       BITCOIN_QT_FAIL([$1 not found])
45     fi
46   ])
49 dnl Initialize qt input.
50 dnl This must be called before any other BITCOIN_QT* macros to ensure that
51 dnl input variables are set correctly.
52 dnl CAUTION: Do not use this inside of a conditional.
53 AC_DEFUN([BITCOIN_QT_INIT],[
54   dnl enable qt support
55   AC_ARG_WITH([gui],
56     [AS_HELP_STRING([--with-gui@<:@=no|qt4|qt5|auto@:>@],
57     [build bitcoin-qt GUI (default=auto, qt5 tried first)])],
58     [
59      bitcoin_qt_want_version=$withval
60      if test x$bitcoin_qt_want_version = xyes; then
61        bitcoin_qt_force=yes
62        bitcoin_qt_want_version=auto
63      fi
64     ],
65     [bitcoin_qt_want_version=auto])
67   AC_ARG_WITH([qt-incdir],[AS_HELP_STRING([--with-qt-incdir=INC_DIR],[specify qt include path (overridden by pkgconfig)])], [qt_include_path=$withval], [])
68   AC_ARG_WITH([qt-libdir],[AS_HELP_STRING([--with-qt-libdir=LIB_DIR],[specify qt lib path (overridden by pkgconfig)])], [qt_lib_path=$withval], [])
69   AC_ARG_WITH([qt-plugindir],[AS_HELP_STRING([--with-qt-plugindir=PLUGIN_DIR],[specify qt plugin path (overridden by pkgconfig)])], [qt_plugin_path=$withval], [])
70   AC_ARG_WITH([qt-translationdir],[AS_HELP_STRING([--with-qt-translationdir=PLUGIN_DIR],[specify qt translation path (overridden by pkgconfig)])], [qt_translation_path=$withval], [])
71   AC_ARG_WITH([qt-bindir],[AS_HELP_STRING([--with-qt-bindir=BIN_DIR],[specify qt bin path])], [qt_bin_path=$withval], [])
73   AC_ARG_WITH([qtdbus],
74     [AS_HELP_STRING([--with-qtdbus],
75     [enable DBus support (default is yes if qt is enabled and QtDBus is found)])],
76     [use_dbus=$withval],
77     [use_dbus=auto])
79   AC_SUBST(QT_TRANSLATION_DIR,$qt_translation_path)
82 dnl Find the appropriate version of Qt libraries and includes.
83 dnl Inputs: $1: Whether or not pkg-config should be used. yes|no. Default: yes.
84 dnl Inputs: $2: If $1 is "yes" and --with-gui=auto, which qt version should be
85 dnl         tried first.
86 dnl Outputs: See _BITCOIN_QT_FIND_LIBS_*
87 dnl Outputs: Sets variables for all qt-related tools.
88 dnl Outputs: bitcoin_enable_qt, bitcoin_enable_qt_dbus, bitcoin_enable_qt_test
89 AC_DEFUN([BITCOIN_QT_CONFIGURE],[
90   use_pkgconfig=$1
92   if test x$use_pkgconfig = x; then
93     use_pkgconfig=yes
94   fi
96   if test x$use_pkgconfig = xyes; then
97     BITCOIN_QT_CHECK([_BITCOIN_QT_FIND_LIBS_WITH_PKGCONFIG([$2])])
98   else
99     BITCOIN_QT_CHECK([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG])
100   fi
102   dnl This is ugly and complicated. Yuck. Works as follows:
103   dnl We can't discern whether Qt4 builds are static or not. For Qt5, we can
104   dnl check a header to find out. When Qt is built statically, some plugins must
105   dnl be linked into the final binary as well. These plugins have changed between
106   dnl Qt4 and Qt5. With Qt5, languages moved into core and the WindowsIntegration
107   dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
108   dnl assumed for windows builds.
109   dnl _BITCOIN_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the
110   dnl results to QT_LIBS.
111   BITCOIN_QT_CHECK([
112   TEMP_CPPFLAGS=$CPPFLAGS
113   TEMP_CXXFLAGS=$CXXFLAGS
114   CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
115   CXXFLAGS="$PIC_FLAGS $CXXFLAGS"
116   if test x$bitcoin_qt_got_major_vers = x5; then
117     _BITCOIN_QT_IS_STATIC
118     if test x$bitcoin_cv_static_qt = xyes; then
119       _BITCOIN_QT_FIND_STATIC_PLUGINS
120       AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
121       AC_CACHE_CHECK(for Qt < 5.4, bitcoin_cv_need_acc_widget,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
122           [[#include <QtCore>]],[[
123           #if QT_VERSION >= 0x050400
124           choke;
125           #endif
126           ]])],
127         [bitcoin_cv_need_acc_widget=yes],
128         [bitcoin_cv_need_acc_widget=no])
129       ])
130       if test "x$bitcoin_cv_need_acc_widget" = "xyes"; then
131         _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets])
132       fi
133       _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin)],[-lqminimal])
134       AC_DEFINE(QT_QPA_PLATFORM_MINIMAL, 1, [Define this symbol if the minimal qt platform exists])
135       if test x$TARGET_OS = xwindows; then
136         _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows])
137         AC_DEFINE(QT_QPA_PLATFORM_WINDOWS, 1, [Define this symbol if the qt platform is windows])
138       elif test x$TARGET_OS = xlinux; then
139         _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)],[-lqxcb -lxcb-static])
140         AC_DEFINE(QT_QPA_PLATFORM_XCB, 1, [Define this symbol if the qt platform is xcb])
141       elif test x$TARGET_OS = xdarwin; then
142         AX_CHECK_LINK_FLAG([[-framework IOKit]],[QT_LIBS="$QT_LIBS -framework IOKit"],[AC_MSG_ERROR(could not iokit framework)])
143         _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)],[-lqcocoa])
144         AC_DEFINE(QT_QPA_PLATFORM_COCOA, 1, [Define this symbol if the qt platform is cocoa])
145       fi
146     fi
147   else
148     if test x$TARGET_OS = xwindows; then
149       AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
150       _BITCOIN_QT_CHECK_STATIC_PLUGINS([
151          Q_IMPORT_PLUGIN(qcncodecs)
152          Q_IMPORT_PLUGIN(qjpcodecs)
153          Q_IMPORT_PLUGIN(qtwcodecs)
154          Q_IMPORT_PLUGIN(qkrcodecs)
155          Q_IMPORT_PLUGIN(AccessibleFactory)],
156          [-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets])
157     fi
158   fi
159   CPPFLAGS=$TEMP_CPPFLAGS
160   CXXFLAGS=$TEMP_CXXFLAGS
161   ])
163   if test x$use_pkgconfig$qt_bin_path = xyes; then
164     if test x$bitcoin_qt_got_major_vers = x5; then
165       qt_bin_path="`$PKG_CONFIG --variable=host_bins Qt5Core 2>/dev/null`"
166     fi
167   fi
169   if test x$use_hardening != xno; then
170     BITCOIN_QT_CHECK([
171     AC_MSG_CHECKING(whether -fPIE can be used with this Qt config)
172     TEMP_CPPFLAGS=$CPPFLAGS
173     TEMP_CXXFLAGS=$CXXFLAGS
174     CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
175     CXXFLAGS="$PIE_FLAGS $CXXFLAGS"
176     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QtCore/qconfig.h>]],
177       [[
178           #if defined(QT_REDUCE_RELOCATIONS)
179               choke;
180           #endif
181       ]])],
182       [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIE_FLAGS ],
183       [ AC_MSG_RESULT(no); QT_PIE_FLAGS=$PIC_FLAGS]
184     )
185     CPPFLAGS=$TEMP_CPPFLAGS
186     CXXFLAGS=$TEMP_CXXFLAGS
187     ])
188   else
189     BITCOIN_QT_CHECK([
190     AC_MSG_CHECKING(whether -fPIC is needed with this Qt config)
191     TEMP_CPPFLAGS=$CPPFLAGS
192     CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
193     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QtCore/qconfig.h>]],
194       [[
195           #if defined(QT_REDUCE_RELOCATIONS)
196               choke;
197           #endif
198       ]])],
199       [ AC_MSG_RESULT(no)],
200       [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIC_FLAGS]
201     )
202     CPPFLAGS=$TEMP_CPPFLAGS
203     ])
204   fi
206   BITCOIN_QT_PATH_PROGS([MOC], [moc-qt${bitcoin_qt_got_major_vers} moc${bitcoin_qt_got_major_vers} moc], $qt_bin_path)
207   BITCOIN_QT_PATH_PROGS([UIC], [uic-qt${bitcoin_qt_got_major_vers} uic${bitcoin_qt_got_major_vers} uic], $qt_bin_path)
208   BITCOIN_QT_PATH_PROGS([RCC], [rcc-qt${bitcoin_qt_got_major_vers} rcc${bitcoin_qt_got_major_vers} rcc], $qt_bin_path)
209   BITCOIN_QT_PATH_PROGS([LRELEASE], [lrelease-qt${bitcoin_qt_got_major_vers} lrelease${bitcoin_qt_got_major_vers} lrelease], $qt_bin_path)
210   BITCOIN_QT_PATH_PROGS([LUPDATE], [lupdate-qt${bitcoin_qt_got_major_vers} lupdate${bitcoin_qt_got_major_vers} lupdate],$qt_bin_path, yes)
212   MOC_DEFS='-DHAVE_CONFIG_H -I$(srcdir)'
213   case $host in
214     *darwin*)
215      BITCOIN_QT_CHECK([
216        MOC_DEFS="${MOC_DEFS} -DQ_OS_MAC"
217        base_frameworks="-framework Foundation -framework ApplicationServices -framework AppKit"
218        AX_CHECK_LINK_FLAG([[$base_frameworks]],[QT_LIBS="$QT_LIBS $base_frameworks"],[AC_MSG_ERROR(could not find base frameworks)])
219      ])
220     ;;
221     *mingw*)
222        BITCOIN_QT_CHECK([
223          AX_CHECK_LINK_FLAG([[-mwindows]],[QT_LDFLAGS="$QT_LDFLAGS -mwindows"],[AC_MSG_WARN(-mwindows linker support not detected)])
224        ])
225   esac
228   dnl enable qt support
229   AC_MSG_CHECKING(whether to build ]AC_PACKAGE_NAME[ GUI)
230   BITCOIN_QT_CHECK([
231     bitcoin_enable_qt=yes
232     bitcoin_enable_qt_test=yes
233     if test x$have_qt_test = xno; then
234       bitcoin_enable_qt_test=no
235     fi
236     bitcoin_enable_qt_dbus=no
237     if test x$use_dbus != xno && test x$have_qt_dbus = xyes; then
238       bitcoin_enable_qt_dbus=yes
239     fi
240     if test x$use_dbus = xyes && test x$have_qt_dbus = xno; then
241       AC_MSG_ERROR("libQtDBus not found. Install libQtDBus or remove --with-qtdbus.")
242     fi
243     if test x$LUPDATE = x; then
244       AC_MSG_WARN("lupdate is required to update qt translations")
245     fi
246   ],[
247     bitcoin_enable_qt=no
248   ])
249   AC_MSG_RESULT([$bitcoin_enable_qt (Qt${bitcoin_qt_got_major_vers})])
251   AC_SUBST(QT_PIE_FLAGS)
252   AC_SUBST(QT_INCLUDES)
253   AC_SUBST(QT_LIBS)
254   AC_SUBST(QT_LDFLAGS)
255   AC_SUBST(QT_DBUS_INCLUDES)
256   AC_SUBST(QT_DBUS_LIBS)
257   AC_SUBST(QT_TEST_INCLUDES)
258   AC_SUBST(QT_TEST_LIBS)
259   AC_SUBST(QT_SELECT, qt${bitcoin_qt_got_major_vers})
260   AC_SUBST(MOC_DEFS)
263 dnl All macros below are internal and should _not_ be used from the main
264 dnl configure.ac.
265 dnl ----
267 dnl Internal. Check if the included version of Qt is Qt5.
268 dnl Requires: INCLUDES must be populated as necessary.
269 dnl Output: bitcoin_cv_qt5=yes|no
270 AC_DEFUN([_BITCOIN_QT_CHECK_QT5],[
271   AC_CACHE_CHECK(for Qt 5, bitcoin_cv_qt5,[
272   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
273     [[#include <QtCore>]],
274     [[
275       #if QT_VERSION < 0x050000
276       choke me
277       #else
278       return 0;
279       #endif
280     ]])],
281     [bitcoin_cv_qt5=yes],
282     [bitcoin_cv_qt5=no])
283 ])])
285 dnl Internal. Check if the linked version of Qt was built as static libs.
286 dnl Requires: Qt5. This check cannot determine if Qt4 is static.
287 dnl Requires: INCLUDES and LIBS must be populated as necessary.
288 dnl Output: bitcoin_cv_static_qt=yes|no
289 dnl Output: Defines QT_STATICPLUGIN if plugins are static.
290 AC_DEFUN([_BITCOIN_QT_IS_STATIC],[
291   AC_CACHE_CHECK(for static Qt, bitcoin_cv_static_qt,[
292   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
293     [[#include <QtCore>]],
294     [[
295       #if defined(QT_STATIC)
296       return 0;
297       #else
298       choke me
299       #endif
300     ]])],
301     [bitcoin_cv_static_qt=yes],
302     [bitcoin_cv_static_qt=no])
303   ])
304   if test xbitcoin_cv_static_qt = xyes; then
305     AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol for static Qt plugins])
306   fi
309 dnl Internal. Check if the link-requirements for static plugins are met.
310 dnl Requires: INCLUDES and LIBS must be populated as necessary.
311 dnl Inputs: $1: A series of Q_IMPORT_PLUGIN().
312 dnl Inputs: $2: The libraries that resolve $1.
313 dnl Output: QT_LIBS is prepended or configure exits.
314 AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_PLUGINS],[
315   AC_MSG_CHECKING(for static Qt plugins: $2)
316   CHECK_STATIC_PLUGINS_TEMP_LIBS="$LIBS"
317   LIBS="$2 $QT_LIBS $LIBS"
318   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
319     #define QT_STATICPLUGIN
320     #include <QtPlugin>
321     $1]],
322     [[return 0;]])],
323     [AC_MSG_RESULT(yes); QT_LIBS="$2 $QT_LIBS"],
324     [AC_MSG_RESULT(no); BITCOIN_QT_FAIL(Could not resolve: $2)])
325   LIBS="$CHECK_STATIC_PLUGINS_TEMP_LIBS"
328 dnl Internal. Find paths necessary for linking qt static plugins
329 dnl Inputs: bitcoin_qt_got_major_vers. 4 or 5.
330 dnl Inputs: qt_plugin_path. optional.
331 dnl Outputs: QT_LIBS is appended
332 AC_DEFUN([_BITCOIN_QT_FIND_STATIC_PLUGINS],[
333   if test x$bitcoin_qt_got_major_vers = x5; then
334       if test x$qt_plugin_path != x; then
335         QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
336         if test -d "$qt_plugin_path/accessible"; then
337           QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
338         fi
339       fi
340      if test x$use_pkgconfig = xyes; then
341      : dnl
342      m4_ifdef([PKG_CHECK_MODULES],[
343        PKG_CHECK_MODULES([QTPLATFORM], [Qt5PlatformSupport], [QT_LIBS="$QTPLATFORM_LIBS $QT_LIBS"])
344        if test x$TARGET_OS = xlinux; then
345          PKG_CHECK_MODULES([X11XCB], [x11-xcb], [QT_LIBS="$X11XCB_LIBS $QT_LIBS"])
346          if ${PKG_CONFIG} --exists "Qt5Core >= 5.5" 2>/dev/null; then
347            PKG_CHECK_MODULES([QTXCBQPA], [Qt5XcbQpa], [QT_LIBS="$QTXCBQPA_LIBS $QT_LIBS"])
348          fi
349        elif test x$TARGET_OS = xdarwin; then
350          PKG_CHECK_MODULES([QTPRINT], [Qt5PrintSupport], [QT_LIBS="$QTPRINT_LIBS $QT_LIBS"])
351        fi
352      ])
353      else
354        if test x$TARGET_OS = xwindows; then
355          AC_CACHE_CHECK(for Qt >= 5.6, bitcoin_cv_need_platformsupport,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
356              [[#include <QtCore>]],[[
357              #if QT_VERSION < 0x050600
358              choke;
359              #endif
360              ]])],
361            [bitcoin_cv_need_platformsupport=yes],
362            [bitcoin_cv_need_platformsupport=no])
363          ])
364          if test x$bitcoin_cv_need_platformsupport = xyes; then
365            BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}PlatformSupport],[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXPlatformSupport not found)))
366          fi
367        fi
368      fi
369   else
370     if test x$qt_plugin_path != x; then
371       QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
372       QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs"
373     fi
374   fi
377 dnl Internal. Find Qt libraries using pkg-config.
378 dnl Inputs: bitcoin_qt_want_version (from --with-gui=). The version to check
379 dnl         first.
380 dnl Inputs: $1: If bitcoin_qt_want_version is "auto", check for this version
381 dnl         first.
382 dnl Outputs: All necessary QT_* variables are set.
383 dnl Outputs: bitcoin_qt_got_major_vers is set to "4" or "5".
384 dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no.
385 AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITH_PKGCONFIG],[
386   m4_ifdef([PKG_CHECK_MODULES],[
387   auto_priority_version=$1
388   if test x$auto_priority_version = x; then
389     auto_priority_version=qt5
390   fi
391     if test x$bitcoin_qt_want_version = xqt5 ||  ( test x$bitcoin_qt_want_version = xauto && test x$auto_priority_version = xqt5 ); then
392       QT_LIB_PREFIX=Qt5
393       bitcoin_qt_got_major_vers=5
394     else
395       QT_LIB_PREFIX=Qt
396       bitcoin_qt_got_major_vers=4
397     fi
398     qt5_modules="Qt5Core Qt5Gui Qt5Network Qt5Widgets"
399     qt4_modules="QtCore QtGui QtNetwork"
400     BITCOIN_QT_CHECK([
401       if test x$bitcoin_qt_want_version = xqt5 || ( test x$bitcoin_qt_want_version = xauto && test x$auto_priority_version = xqt5 ); then
402         PKG_CHECK_MODULES([QT5], [$qt5_modules], [QT_INCLUDES="$QT5_CFLAGS"; QT_LIBS="$QT5_LIBS" have_qt=yes],[have_qt=no])
403       elif test x$bitcoin_qt_want_version = xqt4 || ( test x$bitcoin_qt_want_version = xauto && test x$auto_priority_version = xqt4 ); then
404         PKG_CHECK_MODULES([QT4], [$qt4_modules], [QT_INCLUDES="$QT4_CFLAGS"; QT_LIBS="$QT4_LIBS" ; have_qt=yes], [have_qt=no])
405       fi
407       dnl qt version is set to 'auto' and the preferred version wasn't found. Now try the other.
408       if test x$have_qt = xno && test x$bitcoin_qt_want_version = xauto; then
409         if test x$auto_priority_version = xqt5; then
410           PKG_CHECK_MODULES([QT4], [$qt4_modules], [QT_INCLUDES="$QT4_CFLAGS"; QT_LIBS="$QT4_LIBS" ; have_qt=yes; QT_LIB_PREFIX=Qt; bitcoin_qt_got_major_vers=4], [have_qt=no])
411         else
412           PKG_CHECK_MODULES([QT5], [$qt5_modules], [QT_INCLUDES="$QT5_CFLAGS"; QT_LIBS="$QT5_LIBS" ; have_qt=yes; QT_LIB_PREFIX=Qt5; bitcoin_qt_got_major_vers=5], [have_qt=no])
413         fi
414       fi
415       if test x$have_qt != xyes; then
416         have_qt=no
417         BITCOIN_QT_FAIL([Qt dependencies not found])
418       fi
419     ])
420     BITCOIN_QT_CHECK([
421       PKG_CHECK_MODULES([QT_TEST], [${QT_LIB_PREFIX}Test], [QT_TEST_INCLUDES="$QT_TEST_CFLAGS"; have_qt_test=yes], [have_qt_test=no])
422       if test x$use_dbus != xno; then
423         PKG_CHECK_MODULES([QT_DBUS], [${QT_LIB_PREFIX}DBus], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no])
424       fi
425     ])
426   ])
427   true; dnl
430 dnl Internal. Find Qt libraries without using pkg-config. Version is deduced
431 dnl from the discovered headers.
432 dnl Inputs: bitcoin_qt_want_version (from --with-gui=). The version to use.
433 dnl         If "auto", the version will be discovered by _BITCOIN_QT_CHECK_QT5.
434 dnl Outputs: All necessary QT_* variables are set.
435 dnl Outputs: bitcoin_qt_got_major_vers is set to "4" or "5".
436 dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no.
437 AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
438   TEMP_CPPFLAGS="$CPPFLAGS"
439   TEMP_CXXFLAGS="$CXXFLAGS"
440   CXXFLAGS="$PIC_FLAGS $CXXFLAGS"
441   TEMP_LIBS="$LIBS"
442   BITCOIN_QT_CHECK([
443     if test x$qt_include_path != x; then
444       QT_INCLUDES="-I$qt_include_path -I$qt_include_path/QtCore -I$qt_include_path/QtGui -I$qt_include_path/QtWidgets -I$qt_include_path/QtNetwork -I$qt_include_path/QtTest -I$qt_include_path/QtDBus"
445       CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
446     fi
447   ])
449   BITCOIN_QT_CHECK([AC_CHECK_HEADER([QtPlugin],,BITCOIN_QT_FAIL(QtCore headers missing))])
450   BITCOIN_QT_CHECK([AC_CHECK_HEADER([QApplication],, BITCOIN_QT_FAIL(QtGui headers missing))])
451   BITCOIN_QT_CHECK([AC_CHECK_HEADER([QLocalSocket],, BITCOIN_QT_FAIL(QtNetwork headers missing))])
453   BITCOIN_QT_CHECK([
454     if test x$bitcoin_qt_want_version = xauto; then
455       _BITCOIN_QT_CHECK_QT5
456     fi
457     if test x$bitcoin_cv_qt5 = xyes || test x$bitcoin_qt_want_version = xqt5; then
458       QT_LIB_PREFIX=Qt5
459       bitcoin_qt_got_major_vers=5
460     else
461       QT_LIB_PREFIX=Qt
462       bitcoin_qt_got_major_vers=4
463     fi
464   ])
466   BITCOIN_QT_CHECK([
467     LIBS=
468     if test x$qt_lib_path != x; then
469       LIBS="$LIBS -L$qt_lib_path"
470     fi
472     if test x$TARGET_OS = xwindows; then
473       AC_CHECK_LIB([imm32],      [main],, BITCOIN_QT_FAIL(libimm32 not found))
474     fi
475   ])
477   BITCOIN_QT_CHECK(AC_CHECK_LIB([z] ,[main],,AC_MSG_WARN([zlib not found. Assuming qt has it built-in])))
478   BITCOIN_QT_CHECK(AC_SEARCH_LIBS([png_error] ,[qtpng png],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in])))
479   BITCOIN_QT_CHECK(AC_SEARCH_LIBS([jpeg_create_decompress] ,[qtjpeg jpeg],,AC_MSG_WARN([libjpeg not found. Assuming qt has it built-in])))
480   BITCOIN_QT_CHECK(AC_SEARCH_LIBS([pcre16_exec], [qtpcre pcre16],,AC_MSG_WARN([libpcre16 not found. Assuming qt has it built-in])))
481   BITCOIN_QT_CHECK(AC_SEARCH_LIBS([hb_ot_tags_from_script] ,[qtharfbuzzng harfbuzz],,AC_MSG_WARN([libharfbuzz not found. Assuming qt has it built-in or support is disabled])))
482   BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Core]   ,[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXCore not found)))
483   BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Gui]    ,[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXGui not found)))
484   BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Network],[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXNetwork not found)))
485   if test x$bitcoin_qt_got_major_vers = x5; then
486     BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Widgets],[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXWidgets not found)))
487   fi
488   QT_LIBS="$LIBS"
489   LIBS="$TEMP_LIBS"
491   BITCOIN_QT_CHECK([
492     LIBS=
493     if test x$qt_lib_path != x; then
494       LIBS="-L$qt_lib_path"
495     fi
496     AC_CHECK_LIB([${QT_LIB_PREFIX}Test],      [main],, have_qt_test=no)
497     AC_CHECK_HEADER([QTest],, have_qt_test=no)
498     QT_TEST_LIBS="$LIBS"
499     if test x$use_dbus != xno; then
500       LIBS=
501       if test x$qt_lib_path != x; then
502         LIBS="-L$qt_lib_path"
503       fi
504       AC_CHECK_LIB([${QT_LIB_PREFIX}DBus],      [main],, have_qt_dbus=no)
505       AC_CHECK_HEADER([QtDBus],, have_qt_dbus=no)
506       QT_DBUS_LIBS="$LIBS"
507     fi
508   ])
509   CPPFLAGS="$TEMP_CPPFLAGS"
510   CXXFLAGS="$TEMP_CXXFLAGS"
511   LIBS="$TEMP_LIBS"