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 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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,[
  111. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  112. #include <QtCore/qconfig.h>
  113. #ifndef QT_VERSION
  114. # include <QtCore/qglobal.h>
  115. #endif
  116. ]],
  117. [[
  118. #if QT_VERSION >= 0x050400
  119. choke
  120. #endif
  121. ]])],
  122. [bitcoin_cv_need_acc_widget=yes],
  123. [bitcoin_cv_need_acc_widget=no])
  124. ])
  125. if test "x$bitcoin_cv_need_acc_widget" = xyes; then
  126. _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets])
  127. fi
  128. _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin)],[-lqminimal])
  129. AC_DEFINE(QT_QPA_PLATFORM_MINIMAL, 1, [Define this symbol if the minimal qt platform exists])
  130. if test "x$TARGET_OS" = xwindows; then
  131. _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows])
  132. AC_DEFINE(QT_QPA_PLATFORM_WINDOWS, 1, [Define this symbol if the qt platform is windows])
  133. elif test "x$TARGET_OS" = xlinux; then
  134. _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)],[-lqxcb -lxcb-static])
  135. AC_DEFINE(QT_QPA_PLATFORM_XCB, 1, [Define this symbol if the qt platform is xcb])
  136. elif test "x$TARGET_OS" = xdarwin; then
  137. AX_CHECK_LINK_FLAG([[-framework IOKit]],[QT_LIBS="$QT_LIBS -framework IOKit"],[AC_MSG_ERROR(could not iokit framework)])
  138. _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)],[-lqcocoa])
  139. AC_DEFINE(QT_QPA_PLATFORM_COCOA, 1, [Define this symbol if the qt platform is cocoa])
  140. fi
  141. fi
  142. else
  143. if test "x$TARGET_OS" = xwindows; then
  144. AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
  145. _BITCOIN_QT_CHECK_STATIC_PLUGINS([
  146. Q_IMPORT_PLUGIN(qcncodecs)
  147. Q_IMPORT_PLUGIN(qjpcodecs)
  148. Q_IMPORT_PLUGIN(qtwcodecs)
  149. Q_IMPORT_PLUGIN(qkrcodecs)
  150. Q_IMPORT_PLUGIN(AccessibleFactory)],
  151. [-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets])
  152. fi
  153. fi
  154. CPPFLAGS=$TEMP_CPPFLAGS
  155. CXXFLAGS=$TEMP_CXXFLAGS
  156. ])
  157. if test "x$use_pkgconfig$qt_bin_path" = xyes; then
  158. if test "x$bitcoin_qt_got_major_vers" = x5; then
  159. qt_bin_path="`$PKG_CONFIG --variable=host_bins Qt5Core 2>/dev/null`"
  160. fi
  161. fi
  162. if test "x$use_hardening" != xno; then
  163. BITCOIN_QT_CHECK([
  164. AC_MSG_CHECKING(whether -fPIE can be used with this Qt config)
  165. TEMP_CPPFLAGS=$CPPFLAGS
  166. TEMP_CXXFLAGS=$CXXFLAGS
  167. CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
  168. CXXFLAGS="$PIE_FLAGS $CXXFLAGS"
  169. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  170. #include <QtCore/qconfig.h>
  171. #ifndef QT_VERSION
  172. # include <QtCore/qglobal.h>
  173. #endif
  174. ]],
  175. [[
  176. #if defined(QT_REDUCE_RELOCATIONS)
  177. choke
  178. #endif
  179. ]])],
  180. [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIE_FLAGS ],
  181. [ AC_MSG_RESULT(no); QT_PIE_FLAGS=$PIC_FLAGS]
  182. )
  183. CPPFLAGS=$TEMP_CPPFLAGS
  184. CXXFLAGS=$TEMP_CXXFLAGS
  185. ])
  186. else
  187. BITCOIN_QT_CHECK([
  188. AC_MSG_CHECKING(whether -fPIC is needed with this Qt config)
  189. TEMP_CPPFLAGS=$CPPFLAGS
  190. CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
  191. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  192. #include <QtCore/qconfig.h>
  193. #ifndef QT_VERSION
  194. # include <QtCore/qglobal.h>
  195. #endif
  196. ]],
  197. [[
  198. #if defined(QT_REDUCE_RELOCATIONS)
  199. choke
  200. #endif
  201. ]])],
  202. [ AC_MSG_RESULT(no)],
  203. [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIC_FLAGS]
  204. )
  205. CPPFLAGS=$TEMP_CPPFLAGS
  206. ])
  207. fi
  208. BITCOIN_QT_PATH_PROGS([MOC], [moc-qt${bitcoin_qt_got_major_vers} moc${bitcoin_qt_got_major_vers} moc], $qt_bin_path)
  209. BITCOIN_QT_PATH_PROGS([UIC], [uic-qt${bitcoin_qt_got_major_vers} uic${bitcoin_qt_got_major_vers} uic], $qt_bin_path)
  210. BITCOIN_QT_PATH_PROGS([RCC], [rcc-qt${bitcoin_qt_got_major_vers} rcc${bitcoin_qt_got_major_vers} rcc], $qt_bin_path)
  211. BITCOIN_QT_PATH_PROGS([LRELEASE], [lrelease-qt${bitcoin_qt_got_major_vers} lrelease${bitcoin_qt_got_major_vers} lrelease], $qt_bin_path)
  212. BITCOIN_QT_PATH_PROGS([LUPDATE], [lupdate-qt${bitcoin_qt_got_major_vers} lupdate${bitcoin_qt_got_major_vers} lupdate],$qt_bin_path, yes)
  213. MOC_DEFS='-DHAVE_CONFIG_H -I$(srcdir)'
  214. case $host in
  215. *darwin*)
  216. BITCOIN_QT_CHECK([
  217. MOC_DEFS="${MOC_DEFS} -DQ_OS_MAC"
  218. base_frameworks="-framework Foundation -framework ApplicationServices -framework AppKit"
  219. AX_CHECK_LINK_FLAG([[$base_frameworks]],[QT_LIBS="$QT_LIBS $base_frameworks"],[AC_MSG_ERROR(could not find base frameworks)])
  220. ])
  221. ;;
  222. *mingw*)
  223. BITCOIN_QT_CHECK([
  224. AX_CHECK_LINK_FLAG([[-mwindows]],[QT_LDFLAGS="$QT_LDFLAGS -mwindows"],[AC_MSG_WARN(-mwindows linker support not detected)])
  225. ])
  226. esac
  227. dnl enable qt support
  228. AC_MSG_CHECKING(whether to build ]AC_PACKAGE_NAME[ GUI)
  229. BITCOIN_QT_CHECK([
  230. bitcoin_enable_qt=yes
  231. bitcoin_enable_qt_test=yes
  232. if test "x$have_qt_test" = xno; then
  233. bitcoin_enable_qt_test=no
  234. fi
  235. bitcoin_enable_qt_dbus=no
  236. if test "x$use_dbus" != xno && test "x$have_qt_dbus" = xyes; then
  237. bitcoin_enable_qt_dbus=yes
  238. fi
  239. if test "x$use_dbus" = xyes && test "x$have_qt_dbus" = xno; then
  240. AC_MSG_ERROR([libQtDBus not found. Install libQtDBus or remove --with-qtdbus.])
  241. fi
  242. if test "x$LUPDATE" = x; then
  243. AC_MSG_WARN([lupdate is required to update qt translations])
  244. fi
  245. ],[
  246. bitcoin_enable_qt=no
  247. ])
  248. AC_MSG_RESULT([$bitcoin_enable_qt (Qt${bitcoin_qt_got_major_vers})])
  249. AC_SUBST(QT_PIE_FLAGS)
  250. AC_SUBST(QT_INCLUDES)
  251. AC_SUBST(QT_LIBS)
  252. AC_SUBST(QT_LDFLAGS)
  253. AC_SUBST(QT_DBUS_INCLUDES)
  254. AC_SUBST(QT_DBUS_LIBS)
  255. AC_SUBST(QT_TEST_INCLUDES)
  256. AC_SUBST(QT_TEST_LIBS)
  257. AC_SUBST(QT_SELECT, qt${bitcoin_qt_got_major_vers})
  258. AC_SUBST(MOC_DEFS)
  259. ])
  260. dnl All macros below are internal and should _not_ be used from the main
  261. dnl configure.ac.
  262. dnl ----
  263. dnl Internal. Check if the included version of Qt is Qt5.
  264. dnl Requires: INCLUDES must be populated as necessary.
  265. dnl Output: bitcoin_cv_qt5=yes|no
  266. AC_DEFUN([_BITCOIN_QT_CHECK_QT5],[
  267. AC_CACHE_CHECK(for Qt 5, bitcoin_cv_qt5,[
  268. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  269. #include <QtCore/qconfig.h>
  270. #ifndef QT_VERSION
  271. # include <QtCore/qglobal.h>
  272. #endif
  273. ]],
  274. [[
  275. #if QT_VERSION < 0x050000
  276. choke
  277. #endif
  278. ]])],
  279. [bitcoin_cv_qt5=yes],
  280. [bitcoin_cv_qt5=no])
  281. ])])
  282. dnl Internal. Check if the linked version of Qt was built as static libs.
  283. dnl Requires: Qt5. This check cannot determine if Qt4 is static.
  284. dnl Requires: INCLUDES and LIBS must be populated as necessary.
  285. dnl Output: bitcoin_cv_static_qt=yes|no
  286. dnl Output: Defines QT_STATICPLUGIN if plugins are static.
  287. AC_DEFUN([_BITCOIN_QT_IS_STATIC],[
  288. AC_CACHE_CHECK(for static Qt, bitcoin_cv_static_qt,[
  289. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  290. #include <QtCore/qconfig.h>
  291. #ifndef QT_VERSION
  292. # include <QtCore/qglobal.h>
  293. #endif
  294. ]],
  295. [[
  296. #if !defined(QT_STATIC)
  297. choke
  298. #endif
  299. ]])],
  300. [bitcoin_cv_static_qt=yes],
  301. [bitcoin_cv_static_qt=no])
  302. ])
  303. if test "x$bitcoin_cv_static_qt" = xyes; then
  304. AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol for static Qt plugins])
  305. fi
  306. ])
  307. dnl Internal. Check if the link-requirements for static plugins are met.
  308. dnl Requires: INCLUDES and LIBS must be populated as necessary.
  309. dnl Inputs: $1: A series of Q_IMPORT_PLUGIN().
  310. dnl Inputs: $2: The libraries that resolve $1.
  311. dnl Output: QT_LIBS is prepended or configure exits.
  312. AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_PLUGINS],[
  313. AC_MSG_CHECKING(for static Qt plugins: $2)
  314. CHECK_STATIC_PLUGINS_TEMP_LIBS="$LIBS"
  315. LIBS="$2 $QT_LIBS $LIBS"
  316. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  317. #define QT_STATICPLUGIN
  318. #include <QtPlugin>
  319. $1]],
  320. [[return 0;]])],
  321. [AC_MSG_RESULT(yes); QT_LIBS="$2 $QT_LIBS"],
  322. [AC_MSG_RESULT(no); BITCOIN_QT_FAIL(Could not resolve: $2)])
  323. LIBS="$CHECK_STATIC_PLUGINS_TEMP_LIBS"
  324. ])
  325. dnl Internal. Find paths necessary for linking qt static plugins
  326. dnl Inputs: bitcoin_qt_got_major_vers. 4 or 5.
  327. dnl Inputs: qt_plugin_path. optional.
  328. dnl Outputs: QT_LIBS is appended
  329. AC_DEFUN([_BITCOIN_QT_FIND_STATIC_PLUGINS],[
  330. if test "x$bitcoin_qt_got_major_vers" = x5; then
  331. if test "x$qt_plugin_path" != x; then
  332. QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
  333. if test -d "$qt_plugin_path/accessible"; then
  334. QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
  335. fi
  336. fi
  337. if test "x$use_pkgconfig" = xyes; then
  338. : dnl
  339. m4_ifdef([PKG_CHECK_MODULES],[
  340. PKG_CHECK_MODULES([QTPLATFORM], [Qt5PlatformSupport], [QT_LIBS="$QTPLATFORM_LIBS $QT_LIBS"])
  341. if test "x$TARGET_OS" = xlinux; then
  342. PKG_CHECK_MODULES([X11XCB], [x11-xcb], [QT_LIBS="$X11XCB_LIBS $QT_LIBS"])
  343. if ${PKG_CONFIG} --exists "Qt5Core >= 5.5" 2>/dev/null; then
  344. PKG_CHECK_MODULES([QTXCBQPA], [Qt5XcbQpa], [QT_LIBS="$QTXCBQPA_LIBS $QT_LIBS"])
  345. fi
  346. elif test "x$TARGET_OS" = xdarwin; then
  347. PKG_CHECK_MODULES([QTPRINT], [Qt5PrintSupport], [QT_LIBS="$QTPRINT_LIBS $QT_LIBS"])
  348. fi
  349. ])
  350. else
  351. if test "x$TARGET_OS" = xwindows; then
  352. AC_CACHE_CHECK(for Qt >= 5.6, bitcoin_cv_need_platformsupport,[
  353. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  354. #include <QtCore/qconfig.h>
  355. #ifndef QT_VERSION
  356. # include <QtCore/qglobal.h>
  357. #endif
  358. ]],
  359. [[
  360. #if QT_VERSION < 0x050600
  361. choke
  362. #endif
  363. ]])],
  364. [bitcoin_cv_need_platformsupport=yes],
  365. [bitcoin_cv_need_platformsupport=no])
  366. ])
  367. if test "x$bitcoin_cv_need_platformsupport" = xyes; then
  368. BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}PlatformSupport],[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}PlatformSupport not found)))
  369. fi
  370. fi
  371. fi
  372. else
  373. if test "x$qt_plugin_path" != x; then
  374. QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
  375. QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs"
  376. fi
  377. fi
  378. ])
  379. dnl Internal. Find Qt libraries using pkg-config.
  380. dnl Inputs: bitcoin_qt_want_version (from --with-gui=). The version to check
  381. dnl first.
  382. dnl Inputs: $1: If bitcoin_qt_want_version is "auto", check for this version
  383. dnl first.
  384. dnl Outputs: All necessary QT_* variables are set.
  385. dnl Outputs: bitcoin_qt_got_major_vers is set to "4" or "5".
  386. dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no.
  387. AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITH_PKGCONFIG],[
  388. m4_ifdef([PKG_CHECK_MODULES],[
  389. auto_priority_version=$1
  390. if test "x$auto_priority_version" = x; then
  391. auto_priority_version=qt5
  392. fi
  393. if test "x$bitcoin_qt_want_version" = xqt5 || ( test "x$bitcoin_qt_want_version" = xauto && test "x$auto_priority_version" = xqt5 ); then
  394. QT_LIB_PREFIX=Qt5
  395. bitcoin_qt_got_major_vers=5
  396. else
  397. QT_LIB_PREFIX=Qt
  398. bitcoin_qt_got_major_vers=4
  399. fi
  400. qt5_modules="Qt5Core Qt5Gui Qt5Network Qt5Widgets"
  401. qt4_modules="QtCore QtGui QtNetwork"
  402. BITCOIN_QT_CHECK([
  403. if test "x$bitcoin_qt_want_version" = xqt5 || ( test "x$bitcoin_qt_want_version" = xauto && test "x$auto_priority_version" = xqt5 ); then
  404. PKG_CHECK_MODULES([QT5], [$qt5_modules], [QT_INCLUDES="$QT5_CFLAGS"; QT_LIBS="$QT5_LIBS" have_qt=yes],[have_qt=no])
  405. elif test "x$bitcoin_qt_want_version" = xqt4 || ( test "x$bitcoin_qt_want_version" = xauto && test "x$auto_priority_version" = xqt4 ); then
  406. PKG_CHECK_MODULES([QT4], [$qt4_modules], [QT_INCLUDES="$QT4_CFLAGS"; QT_LIBS="$QT4_LIBS" ; have_qt=yes], [have_qt=no])
  407. fi
  408. dnl qt version is set to 'auto' and the preferred version wasn't found. Now try the other.
  409. if test "x$have_qt" = xno && test "x$bitcoin_qt_want_version" = xauto; then
  410. if test "x$auto_priority_version" = xqt5; then
  411. 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])
  412. else
  413. 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])
  414. fi
  415. fi
  416. if test "x$have_qt" != xyes; then
  417. have_qt=no
  418. BITCOIN_QT_FAIL([Qt dependencies not found])
  419. fi
  420. ])
  421. BITCOIN_QT_CHECK([
  422. PKG_CHECK_MODULES([QT_TEST], [${QT_LIB_PREFIX}Test], [QT_TEST_INCLUDES="$QT_TEST_CFLAGS"; have_qt_test=yes], [have_qt_test=no])
  423. if test "x$use_dbus" != xno; then
  424. PKG_CHECK_MODULES([QT_DBUS], [${QT_LIB_PREFIX}DBus], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no])
  425. fi
  426. ])
  427. ])
  428. true; dnl
  429. ])
  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. ])
  448. BITCOIN_QT_CHECK([AC_CHECK_HEADER([QtPlugin],,BITCOIN_QT_FAIL(QtCore headers missing))])
  449. BITCOIN_QT_CHECK([AC_CHECK_HEADER([QApplication],, BITCOIN_QT_FAIL(QtGui headers missing))])
  450. BITCOIN_QT_CHECK([AC_CHECK_HEADER([QLocalSocket],, BITCOIN_QT_FAIL(QtNetwork headers missing))])
  451. BITCOIN_QT_CHECK([
  452. if test "x$bitcoin_qt_want_version" = xauto; then
  453. _BITCOIN_QT_CHECK_QT5
  454. fi
  455. if test "x$bitcoin_cv_qt5" = xyes || test "x$bitcoin_qt_want_version" = xqt5; then
  456. QT_LIB_PREFIX=Qt5
  457. bitcoin_qt_got_major_vers=5
  458. else
  459. QT_LIB_PREFIX=Qt
  460. bitcoin_qt_got_major_vers=4
  461. fi
  462. ])
  463. BITCOIN_QT_CHECK([
  464. LIBS=
  465. if test "x$qt_lib_path" != x; then
  466. LIBS="$LIBS -L$qt_lib_path"
  467. fi
  468. if test "x$TARGET_OS" = xwindows; then
  469. AC_CHECK_LIB([imm32], [main],, BITCOIN_QT_FAIL(libimm32 not found))
  470. fi
  471. ])
  472. BITCOIN_QT_CHECK(AC_CHECK_LIB([z] ,[main],,AC_MSG_WARN([zlib not found. Assuming qt has it built-in])))
  473. BITCOIN_QT_CHECK(AC_SEARCH_LIBS([png_error] ,[qtpng png],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in])))
  474. BITCOIN_QT_CHECK(AC_SEARCH_LIBS([jpeg_create_decompress] ,[qtjpeg jpeg],,AC_MSG_WARN([libjpeg not found. Assuming qt has it built-in])))
  475. BITCOIN_QT_CHECK(AC_SEARCH_LIBS([pcre16_exec], [qtpcre pcre16],,AC_MSG_WARN([libpcre16 not found. Assuming qt has it built-in])))
  476. 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])))
  477. BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Core] ,[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Core not found)))
  478. BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Gui] ,[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Gui not found)))
  479. BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Network],[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Network not found)))
  480. if test "x$bitcoin_qt_got_major_vers" = x5; then
  481. BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Widgets],[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Widgets not found)))
  482. fi
  483. QT_LIBS="$LIBS"
  484. LIBS="$TEMP_LIBS"
  485. BITCOIN_QT_CHECK([
  486. LIBS=
  487. if test "x$qt_lib_path" != x; then
  488. LIBS="-L$qt_lib_path"
  489. fi
  490. AC_CHECK_LIB([${QT_LIB_PREFIX}Test], [main],, have_qt_test=no)
  491. AC_CHECK_HEADER([QTest],, have_qt_test=no)
  492. QT_TEST_LIBS="$LIBS"
  493. if test "x$use_dbus" != xno; then
  494. LIBS=
  495. if test "x$qt_lib_path" != x; then
  496. LIBS="-L$qt_lib_path"
  497. fi
  498. AC_CHECK_LIB([${QT_LIB_PREFIX}DBus], [main],, have_qt_dbus=no)
  499. AC_CHECK_HEADER([QtDBus],, have_qt_dbus=no)
  500. QT_DBUS_LIBS="$LIBS"
  501. fi
  502. ])
  503. CPPFLAGS="$TEMP_CPPFLAGS"
  504. CXXFLAGS="$TEMP_CXXFLAGS"
  505. LIBS="$TEMP_LIBS"
  506. ])