changeset 6894:7b5dcd048534

gnuplot: Support native build with Qt6 * src/gnuplot-3-qt6-native.patch: Cherry-pick patch from upstream to allow configure to find Qt6. * src/gnuplot.mk: Add flags to build with Qt6 for native build rules. * dist-files.mk: Add new patch to list.
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 01 Oct 2023 15:32:33 +0200
parents caa19ef0ff93
children c2892f53d123
files dist-files.mk src/gnuplot-3-qt6-native.patch src/gnuplot.mk
diffstat 3 files changed, 158 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dist-files.mk	Sun Oct 01 14:47:09 2023 +0200
+++ b/dist-files.mk	Sun Oct 01 15:32:33 2023 +0200
@@ -151,6 +151,7 @@
   gmp.mk \
   gnuplot-1-fixes.patch \
   gnuplot-2-qt6.patch \
+  gnuplot-3-qt6-native.patch \
   gnuplot.mk \
   gnutls-1-fixes.patch \
   gnutls-test.c \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gnuplot-3-qt6-native.patch	Sun Oct 01 15:32:33 2023 +0200
@@ -0,0 +1,133 @@
+From e458b88e481e8af4ef2d97c9af79fdf40e40ed81 Mon Sep 17 00:00:00 2001
+From: Ethan A Merritt <merritt@u.washington.edu>
+Date: Sun, 30 Jul 2023 11:37:14 -0700
+Subject: [PATCH] configure:   Check for Qt6, fall back to Qt5
+
+Note: requires C++  -std=c++17
+
+Note: requires Qt6 compatibility module Core5Compat
+	for class QTextCodec
+		codecForLocale() codecForMib() fromUnicode() toUnicode()
+	in order to support non-utf8 encodings (gnuplot's "set encoding").
+
+	This is not entirely satisfactory, since there is apparently not
+	a guarantee from Qt that the compatibility modules will continue
+	to be available in the future.
+
+./configure --with-qt=qt4  is still accepted but I no longer have
+the Qt4 libraries installed to confirm that it works.
+---
+ configure.ac                     | 53 ++++++++++++++++++++++----------
+ src/qtterminal/qt_conversion.cpp |  9 ++++++
+ 2 files changed, 45 insertions(+), 17 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 3f98c46d0..ca09c31d2 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1065,29 +1065,48 @@ if test "${enable_qt}" = yes ; then
+       enable_qt_ok=no
+   fi
+ 
+-  dnl First check for Qt5
+-  if test "x${with_qt}" = "xqt5"; then
+-    try_qt4=no
+-  else
++  dnl Qt4 only by special request
++  if test "x${with_qt}" = "xqt4"; then
+     try_qt4=yes
++  else
++    try_qt4=no
+   fi
++
+   if test "x${with_qt}" != "xqt4"; then
+-    PKG_CHECK_MODULES_NOFAIL(QT, [Qt5Core Qt5Gui Qt5Network Qt5Svg Qt5PrintSupport])
++    AC_MSG_CHECKING([Checking for Qt6 support libraries])
++    PKG_CHECK_MODULES_NOFAIL(QT, [Qt6Core Qt6Gui Qt6Network Qt6Svg Qt6PrintSupport Qt6Core5Compat])
+     if test $pkg_failed = no; then
+-      try_qt4=no
+-      QT5LOC=`$PKG_CONFIG --variable=host_bins Qt5Core`
+-      if test "x${QT5LOC}" != "x"; then
+-        UIC=${QT5LOC}/uic
+-        MOC=${QT5LOC}/moc
+-        RCC=${QT5LOC}/rcc
+-        LRELEASE=${QT5LOC}/lrelease
++      QT6LOC=`$PKG_CONFIG --variable=host_bins Qt6Core`
++      if test "x${QT6LOC}" != "x"; then
++        UIC=${QT6LOC}/uic
++        MOC=${QT6LOC}/moc
++        RCC=${QT6LOC}/rcc
++        LRELEASE=${QT6LOC}/lrelease
+       fi
+       CXXFLAGS="$CXXFLAGS -fPIC"
++      AC_MSG_RESULT([The Qt terminal will use Qt6.])
++      QTVER="6"
++    else
++      AC_MSG_CHECKING([Checking for Qt5 support libraries])
++      PKG_CHECK_MODULES_NOFAIL(QT, [Qt5Core Qt5Gui Qt5Network Qt5Svg Qt5PrintSupport])
++      if test $pkg_failed = no; then
++        QT5LOC=`$PKG_CONFIG --variable=host_bins Qt5Core`
++        if test "x${QT5LOC}" != "x"; then
++          UIC=${QT5LOC}/uic
++          MOC=${QT5LOC}/moc
++          RCC=${QT5LOC}/rcc
++          LRELEASE=${QT5LOC}/lrelease
++        fi
++        CXXFLAGS="$CXXFLAGS -fPIC"
++        AC_MSG_RESULT([The Qt terminal will use Qt5.])
++        QTVER="5"
++      fi
+     fi 
+   fi
+ 
+-  dnl No Qt5, check for Qt4.5 or greater
+-  if test ${try_qt4} != no; then
++  dnl Explicit request for qt4 
++  if test ${try_qt4} = yes; then
++    AC_MSG_CHECKING([Checking for Qt4 support])
+     PKG_CHECK_MODULES_NOFAIL(QT, [QtCore >= 4.5 QtGui >= 4.5 QtNetwork >= 4.5 QtSvg >= 4.5])
+     if test $pkg_failed != no; then
+       enable_qt_ok=no
+@@ -1170,9 +1189,6 @@ if test "${enable_qt}" = yes ; then
+       AC_MSG_WARN([The Qt terminal will use Qt4.])
+       QTVER="4"
+     fi
+-  else
+-    AC_MSG_WARN([The Qt terminal will use Qt5.])
+-    QTVER="5"
+   fi
+ fi
+ 
+@@ -1366,6 +1382,9 @@ if test "$enable_qt_ok" = yes; then
+   if test "$QTVER" = 5; then
+       AC_MSG_RESULT([  Qt                   : yes (qt5)])
+   fi
++  if test "$QTVER" = 6; then
++      AC_MSG_RESULT([  Qt                   : yes (qt6)])
++  fi
+ else
+   AC_MSG_RESULT([  Qt                   : no (use --with-qt or --with-qt=qt4 to enable])
+ fi
+diff --git a/src/qtterminal/qt_conversion.cpp b/src/qtterminal/qt_conversion.cpp
+index cf8a20930..a50d357b8 100644
+--- a/src/qtterminal/qt_conversion.cpp
++++ b/src/qtterminal/qt_conversion.cpp
+@@ -41,6 +41,15 @@
+  * under either the GPL or the gnuplot license.
+ ]*/
+ 
++/*
++ * Qt6 no longer supports other 8-bit encodings natively, relegating the
++ * QTextCodec functions to a compatibility module Core5Compat.
++ * FIXME: roll our own?
++ */
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    #include <QTextCodec>
++#endif
++
+ static QColor qt_colorList[12] =
+ {
+ 	Qt::white,
+-- 
+2.38.0.windows.1
+
--- a/src/gnuplot.mk	Sun Oct 01 14:47:09 2023 +0200
+++ b/src/gnuplot.mk	Sun Oct 01 15:32:33 2023 +0200
@@ -102,11 +102,33 @@
         env -u MAKE -u MAKEFLAGS nmake DESTDIR=$(shell (cd '$(HOST_PREFIX)' && pwd -W) | sed -e 's#/#\\\\#g') && \
         env -u MAKE -u MAKEFLAGS nmake DESTDIR=$(shell (cd '$(3)$(HOST_PREFIX)' && pwd -W) | sed -e 's#/#\\\\#g') install
 endef
+
 else
+
+## If we allow the system Qt libraries to be used, then these
+## won't make sense.
+$(PKG)_QT_CONFIGURE_OPTIONS := \
+  MOC=$(MXE_MOC) \
+  UIC=$(MXE_UIC) \
+  RCC=$(MXE_RCC) \
+  LRELEASE=$(MXE_LRELEASE)
+
+ifeq ($(ENABLE_QT),5)
+  $(PKG)_PKG_CONFIG_PATH := "$(HOST_PREFIX)/qt5/lib/pkgconfig:$(HOST_LIBDIR)/pkgconfig"
+  $(PKG)_QT_CONFIGURE_OPTIONS += --with-qt=qt5
+endif
+ifeq ($(ENABLE_QT),6)
+  $(PKG)_PKG_CONFIG_PATH := "$(HOST_PREFIX)/qt6/lib/pkgconfig:$(HOST_LIBDIR)/pkgconfig"
+  $(PKG)_QT_CONFIGURE_OPTIONS += --with-qt=qt6
+endif
+
 define $(PKG)_BUILD
-    cd '$(1)' && ./configure \
+    cd '$(1)' && autoreconf -fi && PKG_CONFIG_PATH=$($(PKG)_PKG_CONFIG_PATH) \
+    ./configure \
       $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) LIBS=-liconv \
-      --without-lua --prefix='$(HOST_PREFIX)'
+      --without-lua \
+      $($(PKG)_QT_CONFIGURE_OPTIONS) \
+      --prefix='$(HOST_PREFIX)'
     make -C '$(1)' -j '$(JOBS)' install DESTDIR='$(3)'
 endef
 endif