@@ -5,7 +5,7 @@ dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
55dnl Helper for cases where a qt dependency is not met.
66dnl Output: If qt version is auto, set bitcoin_enable_qt to false. Else, exit.
77AC_DEFUN ( [ BITCOIN_QT_FAIL] ,[
8- if test "$bitcoin_qt_want_version" = "auto" && test "$bitcoin_qt_force" != "yes" ; then
8+ if test "$bitcoin_qt_want_version" = "auto"; then
99 if test "$bitcoin_enable_qt" != "no"; then
1010 AC_MSG_WARN ( [ $1 ; bitcoin-qt frontend will not be built] )
1111 fi
@@ -53,15 +53,9 @@ dnl CAUTION: Do not use this inside of a conditional.
5353AC_DEFUN ( [ BITCOIN_QT_INIT] ,[
5454 dnl enable qt support
5555 AC_ARG_WITH ( [ gui] ,
56- [ AS_HELP_STRING ( [ --with-gui@<:@ =no|qt5|auto@:>@ ] ,
56+ [ AS_HELP_STRING ( [ --with-gui@<:@ =no|qt5|qt6| auto@:>@ ] ,
5757 [ build bitcoin-qt GUI (default=auto)] ) ] ,
58- [
59- bitcoin_qt_want_version=$withval
60- if test "$bitcoin_qt_want_version" = "yes"; then
61- bitcoin_qt_force=yes
62- bitcoin_qt_want_version=auto
63- fi
64- ] ,
58+ [ bitcoin_qt_want_version=$withval] ,
6559 [ bitcoin_qt_want_version=auto] )
6660
6761 AS_IF ( [ test "$with_gui" = "qt5_debug"] ,
@@ -70,6 +64,12 @@ AC_DEFUN([BITCOIN_QT_INIT],[
7064 [ qt_lib_suffix= ] ) ; bitcoin_qt_want_version=qt5] ,
7165 [ qt_lib_suffix= ] )
7266
67+ AS_IF ( [ test "$with_gui" = "qt6_debug"] ,
68+ [ AS_CASE ( [ $host] ,
69+ [ *darwin*] , [ qt_lib_suffix=_debug] ,
70+ [ qt_lib_suffix= ] ) ; bitcoin_qt_want_version=qt6] ,
71+ [ qt_lib_suffix= ] )
72+
7373 AS_CASE ( [ $host] , [ *android*] , [ qt_lib_suffix=_$ANDROID_ARCH] )
7474
7575 AC_ARG_WITH ( [ qt-incdir] ,[ AS_HELP_STRING ( [ --with-qt-incdir=INC_DIR] ,[ specify qt include path (overridden by pkgconfig)] ) ] , [ qt_include_path=$withval] , [ ] )
@@ -106,6 +106,57 @@ dnl Outputs: bitcoin_enable_qt, bitcoin_enable_qt_dbus, bitcoin_enable_qt_test
106106AC_DEFUN ( [ BITCOIN_QT_CONFIGURE] ,[
107107 qt_version=">= $1 "
108108 qt_lib_prefix="Qt5"
109+ if test "$bitcoin_qt_want_version" = "qt6"; then
110+ qt_lib_prefix="Qt6"
111+ fi
112+
113+ if test "$use_hardening" != "no"; then
114+ BITCOIN_QT_CHECK([
115+ AC_MSG_CHECKING ( [ whether -fPIE can be used with this Qt config] )
116+ TEMP_CPPFLAGS=$CPPFLAGS
117+ TEMP_CXXFLAGS=$CXXFLAGS
118+ CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS"
119+ CXXFLAGS="$PIE_FLAGS $CORE_CXXFLAGS $CXXFLAGS"
120+ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [
121+ #include <QtCore/qconfig.h>
122+ #ifndef QT_VERSION
123+ # include <QtCore/qglobal.h>
124+ #endif
125+ ] ] ,
126+ [ [
127+ #if defined(QT_REDUCE_RELOCATIONS)
128+ choke
129+ #endif
130+ ] ] ) ] ,
131+ [ AC_MSG_RESULT ( [ yes] ) ; QT_PIE_FLAGS=$PIE_FLAGS ] ,
132+ [ AC_MSG_RESULT ( [ no] ) ; QT_PIE_FLAGS=$PIC_FLAGS]
133+ )
134+ CPPFLAGS=$TEMP_CPPFLAGS
135+ CXXFLAGS=$TEMP_CXXFLAGS
136+ ] )
137+ else
138+ BITCOIN_QT_CHECK([
139+ AC_MSG_CHECKING ( [ whether -fPIC is needed with this Qt config] )
140+ TEMP_CPPFLAGS=$CPPFLAGS
141+ CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS"
142+ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [
143+ #include <QtCore/qconfig.h>
144+ #ifndef QT_VERSION
145+ # include <QtCore/qglobal.h>
146+ #endif
147+ ] ] ,
148+ [ [
149+ #if defined(QT_REDUCE_RELOCATIONS)
150+ choke
151+ #endif
152+ ] ] ) ] ,
153+ [ AC_MSG_RESULT ( [ no] ) ] ,
154+ [ AC_MSG_RESULT ( [ yes] ) ; QT_PIE_FLAGS=$PIC_FLAGS]
155+ )
156+ CPPFLAGS=$TEMP_CPPFLAGS
157+ ] )
158+ fi
159+
109160 BITCOIN_QT_CHECK([ _BITCOIN_QT_FIND_LIBS] )
110161
111162 dnl This is ugly and complicated. Yuck. Works as follows:
@@ -120,7 +171,9 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
120171 CXXFLAGS="$PIC_FLAGS $CORE_CXXFLAGS $CXXFLAGS"
121172 _BITCOIN_QT_IS_STATIC
122173 if test "$bitcoin_cv_static_qt" = "yes"; then
123- _BITCOIN_QT_CHECK_STATIC_LIBS
174+ if test "$bitcoin_qt_want_version" != "qt6"; then
175+ _BITCOIN_QT_CHECK_STATIC_LIBS
176+ fi
124177
125178 if test "$qt_plugin_path" != ""; then
126179 if test -d "$qt_plugin_path/platforms"; then
@@ -150,6 +203,9 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
150203 _BITCOIN_QT_CHECK_STATIC_PLUGIN([ QWindowsVistaStylePlugin] , [ -lqwindowsvistastyle] )
151204 AC_DEFINE ( [ QT_QPA_PLATFORM_WINDOWS] , [ 1] , [ Define this symbol if the qt platform is windows] )
152205 elif test "$TARGET_OS" = "linux"; then
206+ if test "$bitcoin_qt_want_version" = "qt6"; then
207+ QT_LIBS="${qt_lib_path}/libQt6XcbQpa.a -lxkbcommon-x11 -lxkbcommon -lxcb-icccm -lxcb-image -lxcb-keysyms -lxcb-randr -lxcb-render-util -lxcb-shm -lxcb-sync -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb-xkb -lxcb $QT_LIBS"
208+ fi
153209 _BITCOIN_QT_CHECK_STATIC_PLUGIN([ QXcbIntegrationPlugin] , [ -lqxcb] )
154210 AC_DEFINE ( [ QT_QPA_PLATFORM_XCB] , [ 1] , [ Define this symbol if the qt platform is xcb] )
155211 elif test "$TARGET_OS" = "darwin"; then
@@ -173,53 +229,6 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
173229 qt_bin_path="`$PKG_CONFIG --variable=host_bins ${qt_lib_prefix}Core 2>/dev/null`"
174230 fi
175231
176- if test "$use_hardening" != "no"; then
177- BITCOIN_QT_CHECK([
178- AC_MSG_CHECKING ( [ whether -fPIE can be used with this Qt config] )
179- TEMP_CPPFLAGS=$CPPFLAGS
180- TEMP_CXXFLAGS=$CXXFLAGS
181- CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS"
182- CXXFLAGS="$PIE_FLAGS $CORE_CXXFLAGS $CXXFLAGS"
183- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [
184- #include <QtCore/qconfig.h>
185- #ifndef QT_VERSION
186- # include <QtCore/qglobal.h>
187- #endif
188- ] ] ,
189- [ [
190- #if defined(QT_REDUCE_RELOCATIONS)
191- choke
192- #endif
193- ] ] ) ] ,
194- [ AC_MSG_RESULT ( [ yes] ) ; QT_PIE_FLAGS=$PIE_FLAGS ] ,
195- [ AC_MSG_RESULT ( [ no] ) ; QT_PIE_FLAGS=$PIC_FLAGS]
196- )
197- CPPFLAGS=$TEMP_CPPFLAGS
198- CXXFLAGS=$TEMP_CXXFLAGS
199- ] )
200- else
201- BITCOIN_QT_CHECK([
202- AC_MSG_CHECKING ( [ whether -fPIC is needed with this Qt config] )
203- TEMP_CPPFLAGS=$CPPFLAGS
204- CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS"
205- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [
206- #include <QtCore/qconfig.h>
207- #ifndef QT_VERSION
208- # include <QtCore/qglobal.h>
209- #endif
210- ] ] ,
211- [ [
212- #if defined(QT_REDUCE_RELOCATIONS)
213- choke
214- #endif
215- ] ] ) ] ,
216- [ AC_MSG_RESULT ( [ no] ) ] ,
217- [ AC_MSG_RESULT ( [ yes] ) ; QT_PIE_FLAGS=$PIC_FLAGS]
218- )
219- CPPFLAGS=$TEMP_CPPFLAGS
220- ] )
221- fi
222-
223232 BITCOIN_QT_PATH_PROGS([ MOC] , [ moc-qt5 moc5 moc] , $qt_bin_path)
224233 BITCOIN_QT_PATH_PROGS([ UIC] , [ uic-qt5 uic5 uic] , $qt_bin_path)
225234 BITCOIN_QT_PATH_PROGS([ RCC] , [ rcc-qt5 rcc5 rcc] , $qt_bin_path)
@@ -363,6 +372,36 @@ AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_LIBS], [
363372 fi
364373] )
365374
375+ dnl Internal. Check whether Qt application can be initialized.
376+ dnl
377+ dnl _BITCOIN_QT_CHECK_APP(APPLICATION_CLASS)
378+ dnl ----------------------------------------
379+ dnl
380+ dnl dnl Requires: QT_INCLUDES and QT_LIBS must be populated as necessary.
381+ dnl Inputs: $1: QCoreApplication, QGuiApplication, or QApplication.
382+ AC_DEFUN ( [ _BITCOIN_QT_CHECK_APP] , [
383+ AC_MSG_CHECKING ( [ for $1 initialization] )
384+ TEMP_CPPFLAGS="$CPPFLAGS"
385+ TEMP_CXXFLAGS="$CXXFLAGS"
386+ TEMP_LIBS="$LIBS"
387+ CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS"
388+ CXXFLAGS="$QT_PIE_FLAGS $CORE_CXXFLAGS $CXXFLAGS"
389+ LIBS="$QT_LIBS"
390+ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
391+ #include <$1 >
392+ ] ] ,
393+ [ [
394+ int argc = 1;
395+ const char* argv = "core";
396+ $1 app(argc, const_cast<char**>(&argv));
397+ ] ] ) ] ,
398+ [ AC_MSG_RESULT ( [ yes] ) ] ,
399+ [ AC_MSG_RESULT ( [ no] ) ; BITCOIN_QT_FAIL([ $1 failed to initialize.] )] )
400+ CXXFLAGS="$TEMP_CXXFLAGS"
401+ LIBS="$TEMP_LIBS"
402+ CPPFLAGS="$TEMP_CPPFLAGS"
403+ ] )
404+
366405dnl Internal. Find Qt libraries using pkg-config.
367406dnl
368407dnl _BITCOIN_QT_FIND_LIBS
@@ -372,16 +411,34 @@ dnl Outputs: All necessary QT_* variables are set.
372411dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no.
373412AC_DEFUN ( [ _BITCOIN_QT_FIND_LIBS] ,[
374413 BITCOIN_QT_CHECK([
375- PKG_CHECK_MODULES([ QT_CORE] , [ ${qt_lib_prefix}Core${qt_lib_suffix} $qt_version] , [ QT_INCLUDES="$QT_CORE_CFLAGS $QT_INCLUDES" QT_LIBS="$QT_CORE_LIBS $QT_LIBS" ] ,
414+ PKG_CHECK_MODULES([ QT_CORE] , [ ${qt_lib_prefix}Core${qt_lib_suffix} $qt_version] , [ ] ,
376415 [ BITCOIN_QT_FAIL([ ${qt_lib_prefix}Core${qt_lib_suffix} $qt_version not found] )] )
416+ if test "$bitcoin_qt_want_version" = "qt6"; then
417+ QT_CORE_LIBS="$QT_CORE_LIBS -lm ${qt_lib_path}/libQt6BundledPcre2.a -ldl -lrt"
418+ fi
419+ QT_INCLUDES="$QT_CORE_CFLAGS $QT_INCLUDES"
420+ QT_LIBS="$QT_CORE_LIBS $QT_LIBS"
421+ _BITCOIN_QT_CHECK_APP([ QCoreApplication] )
377422 ] )
378423 BITCOIN_QT_CHECK([
379- PKG_CHECK_MODULES([ QT_GUI] , [ ${qt_lib_prefix}Gui${qt_lib_suffix} $qt_version] , [ QT_INCLUDES="$QT_GUI_CFLAGS $QT_INCLUDES" QT_LIBS="$QT_GUI_LIBS $QT_LIBS" ] ,
424+ PKG_CHECK_MODULES([ QT_GUI] , [ ${qt_lib_prefix}Gui${qt_lib_suffix} $qt_version] , [ ] ,
380425 [ BITCOIN_QT_FAIL([ ${qt_lib_prefix}Gui${qt_lib_suffix} $qt_version not found] )] )
426+ if test "$bitcoin_qt_want_version" = "qt6"; then
427+ QT_GUI_LIBS="$QT_GUI_LIBS ${qt_lib_path}/libQt6BundledLibpng.a ${qt_lib_path}/libQt6BundledHarfbuzz.a -lfreetype -lfontconfig -lxkbcommon"
428+ fi
429+ QT_INCLUDES="$QT_GUI_CFLAGS $QT_INCLUDES"
430+ QT_LIBS="$QT_GUI_LIBS $QT_LIBS"
431+ _BITCOIN_QT_CHECK_APP([ QGuiApplication] )
381432 ] )
382433 BITCOIN_QT_CHECK([
383- PKG_CHECK_MODULES([ QT_WIDGETS] , [ ${qt_lib_prefix}Widgets${qt_lib_suffix} $qt_version] , [ QT_INCLUDES="$QT_WIDGETS_CFLAGS $QT_INCLUDES" QT_LIBS="$QT_WIDGETS_LIBS $QT_LIBS" ] ,
434+ PKG_CHECK_MODULES([ QT_WIDGETS] , [ ${qt_lib_prefix}Widgets${qt_lib_suffix} $qt_version] , [ ] ,
384435 [ BITCOIN_QT_FAIL([ ${qt_lib_prefix}Widgets${qt_lib_suffix} $qt_version not found] )] )
436+ if test "$bitcoin_qt_want_version" = "qt6"; then
437+ QT_WIDGETS_LIBS="$QT_WIDGETS_LIBS ${qt_lib_path}/objects-Release/Widgets_resources_1/.rcc/qrc_qstyle.cpp.o ${qt_lib_path}/objects-Release/Widgets_resources_2/.rcc/qrc_qstyle1.cpp.o ${qt_lib_path}/objects-Release/Widgets_resources_3/.rcc/qrc_qmessagebox.cpp.o"
438+ fi
439+ QT_INCLUDES="$QT_WIDGETS_CFLAGS $QT_INCLUDES"
440+ QT_LIBS="$QT_WIDGETS_LIBS $QT_LIBS"
441+ _BITCOIN_QT_CHECK_APP([ QApplication] )
385442 ] )
386443 BITCOIN_QT_CHECK([
387444 PKG_CHECK_MODULES([ QT_NETWORK] , [ ${qt_lib_prefix}Network${qt_lib_suffix} $qt_version] , [ QT_INCLUDES="$QT_NETWORK_CFLAGS $QT_INCLUDES" QT_LIBS="$QT_NETWORK_LIBS $QT_LIBS"] ,
0 commit comments