Skip to content

Commit 773c1f2

Browse files
committed
Merge pull request #4554
2d89ea9 build: fix whitespace in pkg-config variable (Cory Fields) ab123ad build: allow linux and osx to build against static qt5 (Cory Fields)
2 parents d3cb2b8 + 2d89ea9 commit 773c1f2

File tree

3 files changed

+71
-50
lines changed

3 files changed

+71
-50
lines changed

configure.ac

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ case $host in
258258

259259
CPPFLAGS="$CPPFLAGS -DMAC_OSX"
260260
;;
261+
*linux*)
262+
TARGET_OS=linux
263+
;;
261264
*)
262265
;;
263266
esac
@@ -523,7 +526,7 @@ BITCOIN_QT_INIT
523526

524527
if test x$use_pkgconfig = xyes; then
525528

526-
if test x$PKG_CONFIG == x; then
529+
if test x"$PKG_CONFIG" == "x"; then
527530
AC_MSG_ERROR(pkg-config not found.)
528531
fi
529532

src/m4/bitcoin_qt.m4

Lines changed: 61 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,68 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
8686
fi
8787
8888
if test x$use_pkgconfig = xyes; then
89-
if test x$PKG_CONFIG == x; then
90-
AC_MSG_ERROR(pkg-config not found.)
91-
fi
9289
BITCOIN_QT_CHECK([_BITCOIN_QT_FIND_LIBS_WITH_PKGCONFIG([$2])])
9390
else
9491
BITCOIN_QT_CHECK([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG])
9592
fi
9693
94+
dnl This is ugly and complicated. Yuck. Works as follows:
95+
dnl We can't discern whether Qt4 builds are static or not. For Qt5, we can
96+
dnl check a header to find out. When Qt is built statically, some plugins must
97+
dnl be linked into the final binary as well. These plugins have changed between
98+
dnl Qt4 and Qt5. With Qt5, languages moved into core and the WindowsIntegration
99+
dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
100+
dnl assumed for windows builds.
101+
dnl _BITCOIN_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the
102+
dnl results to QT_LIBS.
103+
BITCOIN_QT_CHECK([
104+
TEMP_CPPFLAGS=$CPPFLAGS
105+
CPPFLAGS=$QT_INCLUDES
106+
if test x$bitcoin_qt_got_major_vers == x5; then
107+
_BITCOIN_QT_IS_STATIC
108+
if test x$bitcoin_cv_static_qt == xyes; then
109+
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
110+
if test x$qt_plugin_path != x; then
111+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
112+
if test x$bitcoin_qt_got_major_vers == x5; then
113+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
114+
else
115+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs"
116+
fi
117+
fi
118+
if test x$use_pkgconfig = xyes; then
119+
PKG_CHECK_MODULES([QTPLATFORM], [Qt5PlatformSupport], [QT_LIBS="$QTPLATFORM_LIBS $QT_LIBS"])
120+
fi
121+
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets])
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 -lxcb])
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+
if test x$use_pkgconfig = xyes; then
130+
PKG_CHECK_MODULES([QTPRINT], [Qt5PrintSupport], [QT_LIBS="$QTPRINT_LIBS $QT_LIBS"])
131+
fi
132+
AX_CHECK_LINK_FLAG([[-framework IOKit]],[QT_LIBS="$QT_LIBS -framework IOKit"],[AC_MSG_ERROR(could not iokit framework)])
133+
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)],[-lqcocoa])
134+
AC_DEFINE(QT_QPA_PLATFORM_COCOA, 1, [Define this symbol if the qt platform is cocoa])
135+
fi
136+
fi
137+
else
138+
if test x$TARGET_OS == xwindows; then
139+
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
140+
_BITCOIN_QT_CHECK_STATIC_PLUGINS([
141+
Q_IMPORT_PLUGIN(qcncodecs)
142+
Q_IMPORT_PLUGIN(qjpcodecs)
143+
Q_IMPORT_PLUGIN(qtwcodecs)
144+
Q_IMPORT_PLUGIN(qkrcodecs)
145+
Q_IMPORT_PLUGIN(AccessibleFactory)],
146+
[-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets])
147+
fi
148+
fi
149+
CPPFLAGS=$TEMP_CPPFLAGS
150+
])
97151
BITCOIN_QT_PATH_PROGS([MOC], [moc-qt${bitcoin_qt_got_major_vers} moc${bitcoin_qt_got_major_vers} moc], $qt_bin_path)
98152
BITCOIN_QT_PATH_PROGS([UIC], [uic-qt${bitcoin_qt_got_major_vers} uic${bitcoin_qt_got_major_vers} uic], $qt_bin_path)
99153
BITCOIN_QT_PATH_PROGS([RCC], [rcc-qt${bitcoin_qt_got_major_vers} rcc${bitcoin_qt_got_major_vers} rcc], $qt_bin_path)
@@ -303,26 +357,15 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
303357
])
304358
305359
BITCOIN_QT_CHECK([
306-
LIBS=
307-
if test x$qt_lib_path != x; then
308-
LIBS="$LIBS -L$qt_lib_path"
309-
fi
310-
if test x$qt_plugin_path != x; then
311-
LIBS="$LIBS -L$qt_plugin_path/accessible"
312-
if test x$bitcoin_qt_got_major_vers == x5; then
313-
LIBS="$LIBS -L$qt_plugin_path/platforms"
314-
else
315-
LIBS="$LIBS -L$qt_plugin_path/codecs"
316-
fi
317-
fi
318-
319360
if test x$TARGET_OS == xwindows; then
320361
AC_CHECK_LIB([imm32], [main],, BITCOIN_QT_FAIL(libimm32 not found))
321362
fi
322363
])
323364
324-
BITCOIN_QT_CHECK(AC_CHECK_LIB([z] ,[main],,BITCOIN_QT_FAIL(zlib not found)))
325-
BITCOIN_QT_CHECK(AC_CHECK_LIB([png] ,[main],,BITCOIN_QT_FAIL(png not found)))
365+
BITCOIN_QT_CHECK(AC_CHECK_LIB([z] ,[main],,AC_MSG_WARN([zlib not found. Assuming qt has it built-in])))
366+
BITCOIN_QT_CHECK(AC_CHECK_LIB([png] ,[main],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in])))
367+
BITCOIN_QT_CHECK(AC_CHECK_LIB([jpeg] ,[main],,AC_MSG_WARN([libjpeg not found. Assuming qt has it built-in])))
368+
BITCOIN_QT_CHECK(AC_CHECK_LIB([pcre] ,[main],,AC_MSG_WARN([libpcre not found. Assuming qt has it built-in])))
326369
BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Core] ,[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXCore not found)))
327370
BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Gui] ,[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXGui not found)))
328371
BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Network],[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXNetwork not found)))
@@ -332,37 +375,6 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
332375
QT_LIBS="$LIBS"
333376
LIBS="$TEMP_LIBS"
334377
335-
dnl This is ugly and complicated. Yuck. Works as follows:
336-
dnl We can't discern whether Qt4 builds are static or not. For Qt5, we can
337-
dnl check a header to find out. When Qt is built statically, some plugins must
338-
dnl be linked into the final binary as well. These plugins have changed between
339-
dnl Qt4 and Qt5. With Qt5, languages moved into core and the WindowsIntegration
340-
dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
341-
dnl assumed for all non-pkg-config builds.
342-
dnl _BITCOIN_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the
343-
dnl results to QT_LIBS.
344-
BITCOIN_QT_CHECK([
345-
if test x$bitcoin_qt_got_major_vers == x5; then
346-
_BITCOIN_QT_IS_STATIC
347-
if test x$bitcoin_cv_static_qt == xyes; then
348-
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
349-
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets])
350-
if test x$TARGET_OS == xwindows; then
351-
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows])
352-
fi
353-
fi
354-
else
355-
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
356-
_BITCOIN_QT_CHECK_STATIC_PLUGINS([
357-
Q_IMPORT_PLUGIN(qcncodecs)
358-
Q_IMPORT_PLUGIN(qjpcodecs)
359-
Q_IMPORT_PLUGIN(qtwcodecs)
360-
Q_IMPORT_PLUGIN(qkrcodecs)
361-
Q_IMPORT_PLUGIN(AccessibleFactory)],
362-
[-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets])
363-
fi
364-
])
365-
366378
BITCOIN_QT_CHECK([
367379
LIBS=
368380
if test x$qt_lib_path != x; then

src/qt/bitcoin.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ Q_IMPORT_PLUGIN(qkrcodecs)
5353
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
5454
#else
5555
Q_IMPORT_PLUGIN(AccessibleFactory)
56+
#if defined(QT_QPA_PLATFORM_XCB)
57+
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
58+
#elif defined(QT_QPA_PLATFORM_WINDOWS)
5659
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
60+
#elif defined(QT_QPA_PLATFORM_COCOA)
61+
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
62+
#endif
5763
#endif
5864
#endif
5965

0 commit comments

Comments
 (0)