Skip to content

Commit ab123ad

Browse files
committed
build: allow linux and osx to build against static qt5
This is the first part of a huge effort to rework the handling of dependencies. To start, this change allows all supported platforms to build against a static Qt. 5.2.1 and 5.3 have been successfully tested against osx64, win32, win64, linux32, and linux64. It also makes a small change to the windows config, to allow linking against qt builds with or without built-in libjpeg/libpng/libpcre/libz. The actual build processes to take advantage of these changes (for gitian and pull-tester) are coming soon. Until then, this should be a no-op.
1 parent e8d4cb8 commit ab123ad

File tree

3 files changed

+70
-46
lines changed

3 files changed

+70
-46
lines changed

configure.ac

Lines changed: 3 additions & 0 deletions
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

src/m4/bitcoin_qt.m4

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,63 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
9494
BITCOIN_QT_CHECK([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG])
9595
fi
9696
97+
dnl This is ugly and complicated. Yuck. Works as follows:
98+
dnl We can't discern whether Qt4 builds are static or not. For Qt5, we can
99+
dnl check a header to find out. When Qt is built statically, some plugins must
100+
dnl be linked into the final binary as well. These plugins have changed between
101+
dnl Qt4 and Qt5. With Qt5, languages moved into core and the WindowsIntegration
102+
dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
103+
dnl assumed for windows builds.
104+
dnl _BITCOIN_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the
105+
dnl results to QT_LIBS.
106+
BITCOIN_QT_CHECK([
107+
TEMP_CPPFLAGS=$CPPFLAGS
108+
CPPFLAGS=$QT_INCLUDES
109+
if test x$bitcoin_qt_got_major_vers == x5; then
110+
_BITCOIN_QT_IS_STATIC
111+
if test x$bitcoin_cv_static_qt == xyes; then
112+
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
113+
if test x$qt_plugin_path != x; then
114+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
115+
if test x$bitcoin_qt_got_major_vers == x5; then
116+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
117+
else
118+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs"
119+
fi
120+
fi
121+
if test x$use_pkgconfig = xyes; then
122+
PKG_CHECK_MODULES([QTPLATFORM], [Qt5PlatformSupport], [QT_LIBS="$QTPLATFORM_LIBS $QT_LIBS"])
123+
fi
124+
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets])
125+
if test x$TARGET_OS == xwindows; then
126+
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows])
127+
AC_DEFINE(QT_QPA_PLATFORM_WINDOWS, 1, [Define this symbol if the qt platform is windows])
128+
elif test x$TARGET_OS == xlinux; then
129+
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)],[-lqxcb -lxcb-static -lxcb])
130+
AC_DEFINE(QT_QPA_PLATFORM_XCB, 1, [Define this symbol if the qt platform is xcb])
131+
elif test x$TARGET_OS == xdarwin; then
132+
if test x$use_pkgconfig = xyes; then
133+
PKG_CHECK_MODULES([QTPRINT], [Qt5PrintSupport], [QT_LIBS="$QTPRINT_LIBS $QT_LIBS"])
134+
fi
135+
AX_CHECK_LINK_FLAG([[-framework IOKit]],[QT_LIBS="$QT_LIBS -framework IOKit"],[AC_MSG_ERROR(could not iokit framework)])
136+
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)],[-lqcocoa])
137+
AC_DEFINE(QT_QPA_PLATFORM_COCOA, 1, [Define this symbol if the qt platform is cocoa])
138+
fi
139+
fi
140+
else
141+
if test x$TARGET_OS == xwindows; then
142+
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
143+
_BITCOIN_QT_CHECK_STATIC_PLUGINS([
144+
Q_IMPORT_PLUGIN(qcncodecs)
145+
Q_IMPORT_PLUGIN(qjpcodecs)
146+
Q_IMPORT_PLUGIN(qtwcodecs)
147+
Q_IMPORT_PLUGIN(qkrcodecs)
148+
Q_IMPORT_PLUGIN(AccessibleFactory)],
149+
[-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets])
150+
fi
151+
fi
152+
CPPFLAGS=$TEMP_CPPFLAGS
153+
])
97154
BITCOIN_QT_PATH_PROGS([MOC], [moc-qt${bitcoin_qt_got_major_vers} moc${bitcoin_qt_got_major_vers} moc], $qt_bin_path)
98155
BITCOIN_QT_PATH_PROGS([UIC], [uic-qt${bitcoin_qt_got_major_vers} uic${bitcoin_qt_got_major_vers} uic], $qt_bin_path)
99156
BITCOIN_QT_PATH_PROGS([RCC], [rcc-qt${bitcoin_qt_got_major_vers} rcc${bitcoin_qt_got_major_vers} rcc], $qt_bin_path)
@@ -303,26 +360,15 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
303360
])
304361
305362
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-
319363
if test x$TARGET_OS == xwindows; then
320364
AC_CHECK_LIB([imm32], [main],, BITCOIN_QT_FAIL(libimm32 not found))
321365
fi
322366
])
323367
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)))
368+
BITCOIN_QT_CHECK(AC_CHECK_LIB([z] ,[main],,AC_MSG_WARN([zlib not found. Assuming qt has it built-in])))
369+
BITCOIN_QT_CHECK(AC_CHECK_LIB([png] ,[main],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in])))
370+
BITCOIN_QT_CHECK(AC_CHECK_LIB([jpeg] ,[main],,AC_MSG_WARN([libjpeg not found. Assuming qt has it built-in])))
371+
BITCOIN_QT_CHECK(AC_CHECK_LIB([pcre] ,[main],,AC_MSG_WARN([libpcre not found. Assuming qt has it built-in])))
326372
BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Core] ,[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXCore not found)))
327373
BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Gui] ,[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXGui not found)))
328374
BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Network],[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXNetwork not found)))
@@ -332,37 +378,6 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
332378
QT_LIBS="$LIBS"
333379
LIBS="$TEMP_LIBS"
334380
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-
366381
BITCOIN_QT_CHECK([
367382
LIBS=
368383
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)