bitcoin_qt.m4: Improve QT_VERSION tests.

Use '<QtCore/qconfig.h> and '<QtCore/qglobal.h>' for testing QT_VERSION.
This makes the tests work with both Qt4 and Qt5, even if '-fPIC' or '-fPIE'
is not used (the compiler might choke otherwise if QT_REDUCE_RELOCATIONS is
active).
This commit is contained in:
Werner Lemberg 2017-08-22 16:48:26 +02:00 committed by fanquake
parent ea68190132
commit db32a4fd6b
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -118,11 +118,17 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
if test x$bitcoin_cv_static_qt = xyes; then if test x$bitcoin_cv_static_qt = xyes; then
_BITCOIN_QT_FIND_STATIC_PLUGINS _BITCOIN_QT_FIND_STATIC_PLUGINS
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static]) AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
AC_CACHE_CHECK(for Qt < 5.4, bitcoin_cv_need_acc_widget,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM( AC_CACHE_CHECK(for Qt < 5.4, bitcoin_cv_need_acc_widget,[
[[#include <QtCore>]],[[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if QT_VERSION >= 0x050400 #include <QtCore/qconfig.h>
choke; #ifndef QT_VERSION
#endif # include <QtCore/qglobal.h>
#endif
]],
[[
#if QT_VERSION >= 0x050400
choke
#endif
]])], ]])],
[bitcoin_cv_need_acc_widget=yes], [bitcoin_cv_need_acc_widget=yes],
[bitcoin_cv_need_acc_widget=no]) [bitcoin_cv_need_acc_widget=no])
@ -173,11 +179,16 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
TEMP_CXXFLAGS=$CXXFLAGS TEMP_CXXFLAGS=$CXXFLAGS
CPPFLAGS="$QT_INCLUDES $CPPFLAGS" CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
CXXFLAGS="$PIE_FLAGS $CXXFLAGS" CXXFLAGS="$PIE_FLAGS $CXXFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QtCore/qconfig.h>]], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <QtCore/qconfig.h>
#ifndef QT_VERSION
# include <QtCore/qglobal.h>
#endif
]],
[[ [[
#if defined(QT_REDUCE_RELOCATIONS) #if defined(QT_REDUCE_RELOCATIONS)
choke; choke
#endif #endif
]])], ]])],
[ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIE_FLAGS ], [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIE_FLAGS ],
[ AC_MSG_RESULT(no); QT_PIE_FLAGS=$PIC_FLAGS] [ AC_MSG_RESULT(no); QT_PIE_FLAGS=$PIC_FLAGS]
@ -190,11 +201,16 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
AC_MSG_CHECKING(whether -fPIC is needed with this Qt config) AC_MSG_CHECKING(whether -fPIC is needed with this Qt config)
TEMP_CPPFLAGS=$CPPFLAGS TEMP_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$QT_INCLUDES $CPPFLAGS" CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QtCore/qconfig.h>]], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <QtCore/qconfig.h>
#ifndef QT_VERSION
# include <QtCore/qglobal.h>
#endif
]],
[[ [[
#if defined(QT_REDUCE_RELOCATIONS) #if defined(QT_REDUCE_RELOCATIONS)
choke; choke
#endif #endif
]])], ]])],
[ AC_MSG_RESULT(no)], [ AC_MSG_RESULT(no)],
[ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIC_FLAGS] [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIC_FLAGS]
@ -269,13 +285,15 @@ dnl Requires: INCLUDES must be populated as necessary.
dnl Output: bitcoin_cv_qt5=yes|no dnl Output: bitcoin_cv_qt5=yes|no
AC_DEFUN([_BITCOIN_QT_CHECK_QT5],[ AC_DEFUN([_BITCOIN_QT_CHECK_QT5],[
AC_CACHE_CHECK(for Qt 5, bitcoin_cv_qt5,[ AC_CACHE_CHECK(for Qt 5, bitcoin_cv_qt5,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM( AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[[#include <QtCore>]], #include <QtCore/qconfig.h>
#ifndef QT_VERSION
# include <QtCore/qglobal.h>
#endif
]],
[[ [[
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
choke me choke
#else
return 0;
#endif #endif
]])], ]])],
[bitcoin_cv_qt5=yes], [bitcoin_cv_qt5=yes],
@ -289,13 +307,15 @@ dnl Output: bitcoin_cv_static_qt=yes|no
dnl Output: Defines QT_STATICPLUGIN if plugins are static. dnl Output: Defines QT_STATICPLUGIN if plugins are static.
AC_DEFUN([_BITCOIN_QT_IS_STATIC],[ AC_DEFUN([_BITCOIN_QT_IS_STATIC],[
AC_CACHE_CHECK(for static Qt, bitcoin_cv_static_qt,[ AC_CACHE_CHECK(for static Qt, bitcoin_cv_static_qt,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM( AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[[#include <QtCore>]], #include <QtCore/qconfig.h>
#ifndef QT_VERSION
# include <QtCore/qglobal.h>
#endif
]],
[[ [[
#if defined(QT_STATIC) #if !defined(QT_STATIC)
return 0; choke
#else
choke me
#endif #endif
]])], ]])],
[bitcoin_cv_static_qt=yes], [bitcoin_cv_static_qt=yes],
@ -352,11 +372,17 @@ AC_DEFUN([_BITCOIN_QT_FIND_STATIC_PLUGINS],[
]) ])
else else
if test x$TARGET_OS = xwindows; then if test x$TARGET_OS = xwindows; then
AC_CACHE_CHECK(for Qt >= 5.6, bitcoin_cv_need_platformsupport,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM( AC_CACHE_CHECK(for Qt >= 5.6, bitcoin_cv_need_platformsupport,[
[[#include <QtCore>]],[[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if QT_VERSION < 0x050600 #include <QtCore/qconfig.h>
choke; #ifndef QT_VERSION
#endif # include <QtCore/qglobal.h>
#endif
]],
[[
#if QT_VERSION < 0x050600
choke
#endif
]])], ]])],
[bitcoin_cv_need_platformsupport=yes], [bitcoin_cv_need_platformsupport=yes],
[bitcoin_cv_need_platformsupport=no]) [bitcoin_cv_need_platformsupport=no])