Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/qt6/qt6base: Make qmake work
@ 2024-04-11 14:55 Ben Hutchings via buildroot
  2024-04-11 14:55 ` [Buildroot] [PATCH] package/qt6/qt6base: Restore DirectFB support Ben Hutchings via buildroot
  2024-09-14 16:16 ` [Buildroot] [PATCH] package/qt6/qt6base: Make qmake work Thomas Petazzoni via buildroot
  0 siblings, 2 replies; 7+ messages in thread
From: Ben Hutchings via buildroot @ 2024-04-11 14:55 UTC (permalink / raw)
  To: buildroot; +Cc: Ben Hutchings

Currently the qt6base package does not install a working qmake
program, so applications can only be built with CMake.

To ease upgrades from Qt 5, make qmake work as well:

- Create a linux-buildroot-g++ device spec, like we do for Qt 5.

- Fix the generated target_qt.conf file.  The Qt build system
  currently generates this with the sysroot directory wrongly added in
  various places.

- Fix the qmake wrapper script in the sysroot to set the QMAKEPATH
  environment variable.

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
---
 package/qt6/qt6base/qmake.conf.in     | 34 +++++++++++++++++++++++
 package/qt6/qt6base/qplatformdefs.h   |  1 +
 package/qt6/qt6base/qt6base.mk        | 39 +++++++++++++++++++++++++++
 package/qt6/qt6base/target_qt.conf.in | 11 ++++++++
 4 files changed, 85 insertions(+)
 create mode 100644 package/qt6/qt6base/qmake.conf.in
 create mode 100644 package/qt6/qt6base/qplatformdefs.h
 create mode 100644 package/qt6/qt6base/target_qt.conf.in

diff --git a/package/qt6/qt6base/qmake.conf.in b/package/qt6/qt6base/qmake.conf.in
new file mode 100644
index 0000000000..b62a671c35
--- /dev/null
+++ b/package/qt6/qt6base/qmake.conf.in
@@ -0,0 +1,34 @@
+# Qt6 has a mechanism to support "device" profiles, so that people can
+# specify the compiler, compiler flags and so on for a specific device.
+
+# We leverage this mechanism in the Buildroot packaging of qt6 to
+# simplify cross-compilation: we have our own "device" definition, which
+# allows us to easily pass the cross-compiler paths and flags from our
+# qt6.mk.
+
+CROSS_COMPILE = @CROSS_COMPILE@
+
+include(../common/linux_device_pre.conf)
+
+# modifications to gcc-base.conf
+QMAKE_CFLAGS           += $${BR_COMPILER_CFLAGS}
+QMAKE_CXXFLAGS         += $${BR_COMPILER_CXXFLAGS}
+# Remove all optimisation flags, we really only want our own.
+QMAKE_CFLAGS_OPTIMIZE       =
+QMAKE_CFLAGS_OPTIMIZE_DEBUG =
+QMAKE_CFLAGS_OPTIMIZE_FULL  =
+QMAKE_CFLAGS_OPTIMIZE_SIZE  =
+QMAKE_CFLAGS_DEBUG =
+QMAKE_CXXFLAGS_DEBUG =
+QMAKE_CFLAGS_RELEASE =
+QMAKE_CXXFLAGS_RELEASE =
+CONFIG                 += nostrip
+
+QMAKE_LIBS             += -lrt -lpthread -ldl
+QMAKE_CFLAGS_ISYSTEM   =
+
+# Architecture specific configuration
+include(arch.conf)
+
+include(../common/linux_device_post.conf)
+load(qt_config)
diff --git a/package/qt6/qt6base/qplatformdefs.h b/package/qt6/qt6base/qplatformdefs.h
new file mode 100644
index 0000000000..99e9a27923
--- /dev/null
+++ b/package/qt6/qt6base/qplatformdefs.h
@@ -0,0 +1 @@
+#include "../../linux-g++/qplatformdefs.h"
diff --git a/package/qt6/qt6base/qt6base.mk b/package/qt6/qt6base/qt6base.mk
index 6857725ef5..049d73a84f 100644
--- a/package/qt6/qt6base/qt6base.mk
+++ b/package/qt6/qt6base/qt6base.mk
@@ -78,6 +78,45 @@ QT6BASE_CONF_OPTS += \
 	-DFEATURE_avx512vl=OFF \
 	-DFEATURE_vaes=OFF
 
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
+define QT6BASE_MKSPEC_ARCH_CONFIG
+# Qt 6 needs atomics, which on various architectures are in -latomic
+	printf '!host_build { \n LIBS += -latomic\n }' > \
+		$(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++/arch.conf
+endef
+endif
+
+define QT6BASE_INSTALL_MKSPEC
+	mkdir -p $(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++
+	$(INSTALL) -m 0644 $(QT6BASE_PKGDIR)/qplatformdefs.h \
+		$(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++/
+	sed 's%@CROSS_COMPILE@%$(TARGET_CROSS)%' \
+		< $(QT6BASE_PKGDIR)/qmake.conf.in \
+		> $(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++/qmake.conf
+	touch $(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++/arch.conf
+	$(QT6BASE_MKSPEC_ARCH_CONFIG)
+endef
+
+# The generated broken target_qt.conf is broken, so replace it
+define QT6BASE_INSTALL_TARGET_QT_CONF
+	sed 's%@HOST_DIR@%$(HOST_DIR)%; s%@SYSROOT@%$(STAGING_DIR)%' \
+		< $(QT6BASE_PKGDIR)/target_qt.conf.in \
+		> $(STAGING_DIR)/usr/bin/target_qt.conf
+endef
+
+# The qmake wrapper script doesn't set QMAKEPATH, so qmake doesn't
+# find specs and modules installed for the target
+define QT6BASE_FIX_QMAKE_SCRIPT
+	sed -i '1a\
+export QMAKEPATH=$(STAGING_DIR)/usr' \
+		$(STAGING_DIR)/usr/bin/qmake
+endef
+
+QT6BASE_POST_INSTALL_STAGING_HOOKS += \
+	QT6BASE_INSTALL_MKSPEC \
+	QT6BASE_INSTALL_TARGET_QT_CONF \
+	QT6BASE_FIX_QMAKE_SCRIPT
+
 HOST_QT6BASE_DEPENDENCIES = \
 	host-double-conversion \
 	host-libb2 \
diff --git a/package/qt6/qt6base/target_qt.conf.in b/package/qt6/qt6base/target_qt.conf.in
new file mode 100644
index 0000000000..5702970c47
--- /dev/null
+++ b/package/qt6/qt6base/target_qt.conf.in
@@ -0,0 +1,11 @@
+[Paths]
+Prefix=/usr
+HostPrefix=@HOST_DIR@
+HostBinaries=bin
+HostLibraries=lib
+HostLibraryExecutables=libexec
+HostData=.
+Sysroot=@SYSROOT@
+SysrootifyPrefix=true
+TargetSpec=devices/linux-buildroot-g++
+HostSpec=
-- 
2.39.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [Buildroot] [PATCH] package/qt6/qt6base: Make qmake work
@ 2025-03-12 13:37 Richard Genoud via buildroot
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Genoud via buildroot @ 2025-03-12 13:37 UTC (permalink / raw)
  To: buildroot
  Cc: Jesse Van Gavere, Roy Kollen Svendsen, Thomas Petazzoni,
	Ben Hutchings, Richard Genoud

Currently the qt6base package does not install a working cross-qmake
program, so applications can only be built with CMake.

There's actually a qmake in the staging directory that could be used on
the target (or in a chroot+qemu).
There's the qmake build from the host-qmake package, in the host
directory. This one can build qmake packages for the host.

And the cross-qmake (the one that create a Makfile for
cross-compilation) is missing.

We can't call it host/usr/bin/qmake since it's already taken by the
host-qmake6, but host/usr/bin/tuple-qmake seems to be a good choice,
since it's made for cross-compilation.

This patch is resurrected from:
https://lore.kernel.org/buildroot/20240411145559.1183064-1-ben.hutchings@mind.be/

To ease upgrades from Qt 5, make qmake work as well:

- Create a linux-buildroot-g++ device spec, like we do for Qt 5.

- Generate a target_qt.conf file in the host/usr/bin directory.

- Add a tuple-qmake wrapper script in the host/usr/bin/ directory to set
  the QMAKEPATH environment variable.

Changes from original version:
- Instead of modifying the qmake in the staging directory, we add a
cross-qmake in the host/usr/bin directory.
- The qmake-and-qtpaths-wrapper is modified in order to call the
  cross-qmake also in subprojects, where qmake calls itself.

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
---
 ...x-qmake-wrappers-for-recursive-qmake.patch | 15 +++++++
 package/qt6/qt6base/qmake.conf.in             | 34 +++++++++++++++
 package/qt6/qt6base/qplatformdefs.h           |  1 +
 package/qt6/qt6base/qt6base.mk                | 42 +++++++++++++++++++
 package/qt6/qt6base/target_qt.conf.in         | 11 +++++
 5 files changed, 103 insertions(+)
 create mode 100644 package/qt6/qt6base/0001-fix-qmake-wrappers-for-recursive-qmake.patch
 create mode 100644 package/qt6/qt6base/qmake.conf.in
 create mode 100644 package/qt6/qt6base/qplatformdefs.h
 create mode 100644 package/qt6/qt6base/target_qt.conf.in

diff --git a/package/qt6/qt6base/0001-fix-qmake-wrappers-for-recursive-qmake.patch b/package/qt6/qt6base/0001-fix-qmake-wrappers-for-recursive-qmake.patch
new file mode 100644
index 000000000000..9d6abee4d2ea
--- /dev/null
+++ b/package/qt6/qt6base/0001-fix-qmake-wrappers-for-recursive-qmake.patch
@@ -0,0 +1,15 @@
+--- qt6base-6.4.3/bin/qmake-and-qtpaths-wrapper.in.old	2025-03-05 09:01:11.723198499 +0100
++++ qt6base-6.4.3/bin/qmake-and-qtpaths-wrapper.in	2025-03-05 09:07:14.618403895 +0100
+@@ -1,7 +1,10 @@
+-#!/bin/sh
++#!/bin/bash
+ 
+ # The directory of this script is the expanded absolute path of the "$qt_prefix/bin" directory.
+ script_dir_path=`dirname $0`
+ script_dir_path=`(cd "$script_dir_path"; /bin/pwd)`
+ 
+-@host_qt_bindir@/@tool_name@@tool_version@ -qtconf "$script_dir_path/target_qt.conf" $*
++# bash exec -a permits to change the $0 argument of the executed program
++# like that, the qmake will think it has been called as this wrapper.
++# The goal is to use also this wrapper when qmake calls itself.
++exec -a $0 @host_qt_bindir@/@tool_name@@tool_version@ -qtconf "$script_dir_path/target_qt.conf" $*
diff --git a/package/qt6/qt6base/qmake.conf.in b/package/qt6/qt6base/qmake.conf.in
new file mode 100644
index 000000000000..b62a671c35a8
--- /dev/null
+++ b/package/qt6/qt6base/qmake.conf.in
@@ -0,0 +1,34 @@
+# Qt6 has a mechanism to support "device" profiles, so that people can
+# specify the compiler, compiler flags and so on for a specific device.
+
+# We leverage this mechanism in the Buildroot packaging of qt6 to
+# simplify cross-compilation: we have our own "device" definition, which
+# allows us to easily pass the cross-compiler paths and flags from our
+# qt6.mk.
+
+CROSS_COMPILE = @CROSS_COMPILE@
+
+include(../common/linux_device_pre.conf)
+
+# modifications to gcc-base.conf
+QMAKE_CFLAGS           += $${BR_COMPILER_CFLAGS}
+QMAKE_CXXFLAGS         += $${BR_COMPILER_CXXFLAGS}
+# Remove all optimisation flags, we really only want our own.
+QMAKE_CFLAGS_OPTIMIZE       =
+QMAKE_CFLAGS_OPTIMIZE_DEBUG =
+QMAKE_CFLAGS_OPTIMIZE_FULL  =
+QMAKE_CFLAGS_OPTIMIZE_SIZE  =
+QMAKE_CFLAGS_DEBUG =
+QMAKE_CXXFLAGS_DEBUG =
+QMAKE_CFLAGS_RELEASE =
+QMAKE_CXXFLAGS_RELEASE =
+CONFIG                 += nostrip
+
+QMAKE_LIBS             += -lrt -lpthread -ldl
+QMAKE_CFLAGS_ISYSTEM   =
+
+# Architecture specific configuration
+include(arch.conf)
+
+include(../common/linux_device_post.conf)
+load(qt_config)
diff --git a/package/qt6/qt6base/qplatformdefs.h b/package/qt6/qt6base/qplatformdefs.h
new file mode 100644
index 000000000000..99e9a2792329
--- /dev/null
+++ b/package/qt6/qt6base/qplatformdefs.h
@@ -0,0 +1 @@
+#include "../../linux-g++/qplatformdefs.h"
diff --git a/package/qt6/qt6base/qt6base.mk b/package/qt6/qt6base/qt6base.mk
index a4c56da6018d..af099e398f90 100644
--- a/package/qt6/qt6base/qt6base.mk
+++ b/package/qt6/qt6base/qt6base.mk
@@ -78,6 +78,48 @@ QT6BASE_CONF_OPTS += \
 	-DFEATURE_avx512vl=OFF \
 	-DFEATURE_vaes=OFF
 
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
+define QT6BASE_MKSPEC_ARCH_CONFIG
+# Qt 6 needs atomics, which on various architectures are in -latomic
+	printf '!host_build { \n LIBS += -latomic\n }' > \
+		$(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++/arch.conf
+endef
+endif
+
+define QT6BASE_INSTALL_MKSPEC
+	mkdir -p $(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++
+	$(INSTALL) -m 0644 $(QT6BASE_PKGDIR)/qplatformdefs.h \
+		$(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++/
+	sed 's%@CROSS_COMPILE@%$(TARGET_CROSS)%' \
+		< $(QT6BASE_PKGDIR)/qmake.conf.in \
+		> $(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++/qmake.conf
+	touch $(STAGING_DIR)/usr/mkspecs/devices/linux-buildroot-g++/arch.conf
+	$(QT6BASE_MKSPEC_ARCH_CONFIG)
+endef
+
+# Install the target_qt.conf needed for cross-qmake
+define QT6BASE_INSTALL_TARGET_QT_CONF
+	sed 's%@HOST_DIR@%$(HOST_DIR)%; s%@SYSROOT@%$(STAGING_DIR)%' \
+		< $(QT6BASE_PKGDIR)/target_qt.conf.in \
+		> $(HOST_DIR)/usr/bin/target_qt.conf
+endef
+
+# Create the cross-qmake from the wrapper script in sysroot.
+# This time, we add QMAKEPATH, so that it finds specs and modules
+# installed for the target
+define QT6BASE_INSTALL_CROSS_QMAKE
+	$(INSTALL) -m 0755 $(STAGING_DIR)/usr/bin/qmake \
+		$(TARGET_CROSS)qmake
+	sed -i '1a\
+export QMAKEPATH=$(STAGING_DIR)/usr' \
+		$(TARGET_CROSS)qmake
+endef
+
+QT6BASE_POST_INSTALL_STAGING_HOOKS += \
+	QT6BASE_INSTALL_MKSPEC \
+	QT6BASE_INSTALL_TARGET_QT_CONF \
+	QT6BASE_INSTALL_CROSS_QMAKE
+
 HOST_QT6BASE_DEPENDENCIES = \
 	host-double-conversion \
 	host-libb2 \
diff --git a/package/qt6/qt6base/target_qt.conf.in b/package/qt6/qt6base/target_qt.conf.in
new file mode 100644
index 000000000000..5702970c47f6
--- /dev/null
+++ b/package/qt6/qt6base/target_qt.conf.in
@@ -0,0 +1,11 @@
+[Paths]
+Prefix=/usr
+HostPrefix=@HOST_DIR@
+HostBinaries=bin
+HostLibraries=lib
+HostLibraryExecutables=libexec
+HostData=.
+Sysroot=@SYSROOT@
+SysrootifyPrefix=true
+TargetSpec=devices/linux-buildroot-g++
+HostSpec=
-- 
2.47.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-12 13:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-11 14:55 [Buildroot] [PATCH] package/qt6/qt6base: Make qmake work Ben Hutchings via buildroot
2024-04-11 14:55 ` [Buildroot] [PATCH] package/qt6/qt6base: Restore DirectFB support Ben Hutchings via buildroot
2024-04-11 18:48   ` Yann E. MORIN
2024-04-12 21:18     ` Ben Hutchings via buildroot
2024-09-14 16:44   ` Thomas Petazzoni via buildroot
2024-09-14 16:16 ` [Buildroot] [PATCH] package/qt6/qt6base: Make qmake work Thomas Petazzoni via buildroot
  -- strict thread matches above, loose matches on Subject: below --
2025-03-12 13:37 Richard Genoud via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox