You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bitcoin_qt.m4 20KB

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