Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions frameworks/qt6/cmake.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/cmake.mk

# the bin-path should be determined correctly via cmake or qmake queries,
# but in case scripts call it relying on it in $PATH, add bin/qt6/ to it.
export PATH:=$(STAGING_DIR_HOSTPKG)/bin/qt6:$(PATH)

CMAKE_OPTIONS += \
-DQT_HOST_PATH="$(STAGING_DIR_HOSTPKG)" \
-DQT_QMAKE_TARGET_MKSPEC="linux-openwrt-g++"
#-DCMAKE_TOOLCHAIN_FILE="/tmp/toolchain.cmake"

CMAKE_HOST_OPTIONS += \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_SKIP_RPATH=FALSE \
-DQT_QMAKE_TARGET_MKSPEC="linux-g++"
240 changes: 240 additions & 0 deletions frameworks/qt6/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
#
# Copyright (C) 2020 OpenWrt.org
# Author: Mirko Vogt <mirko-openwrt@nanl.de>
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

# This file contains Qt specific paths and Install definitions,
# which are agnostic to whether projects use cmake or qmake.
# Its main purpose is to provide helper functions for packaging
# software using Qt.

include $(TOPDIR)/rules.mk

QT_INSTALL_PREFIX:=/usr
QT_INSTALL_CONFIGURATION:=/etc/qt6
QT_INSTALL_SYSCONF:=/etc/qt6
QT_INSTALL_LIBS:=$(QT_INSTALL_PREFIX)/lib
QT_INSTALL_DATA:=$(QT_INSTALL_PREFIX)/share/qt6
QT_INSTALL_HEADERS:=$(QT_INSTALL_PREFIX)/include/qt6
QT_INSTALL_CMAKES:=$(QT_INSTALL_LIBS)/cmake
QT_INSTALL_PKGCONFIGS:=$(QT_INSTALL_LIBS)/pkgconfig
QT_INSTALL_BINS:=$(QT_INSTALL_PREFIX)/bin/qt6
QT_INSTALL_DOCS:=$(QT_INSTALL_DATA)/doc
QT_INSTALL_TRANSLATIONS:=$(QT_INSTALL_DATA)/translations
QT_INSTALL_ARCHDATA:=$(QT_INSTALL_LIBS)/qt6
QT_INSTALL_MKSPECS:=$(QT_INSTALL_ARCHDATA)/mkspecs
QT_INSTALL_LIBEXECS:=$(QT_INSTALL_ARCHDATA)/libexec
QT_INSTALL_TESTS:=$(QT_INSTALL_ARCHDATA)/tests
QT_INSTALL_PLUGINS:=$(QT_INSTALL_ARCHDATA)/plugins
QT_INSTALL_METATYPES:=$(QT_INSTALL_ARCHDATA)/metatypes
QT_INSTALL_IMPORTS:=$(QT_INSTALL_ARCHDATA)/imports
QT_INSTALL_QML:=$(QT_INSTALL_ARCHDATA)/qml
QT_INSTALL_EXAMPLES:=$(QT_INSTALL_ARCHDATA)/examples
QT_INSTALL_DEMOS:=$(QT_INSTALL_EXAMPLES)

QT_HOSTPKG_PREFIX:=$(STAGING_DIR_HOSTPKG)
QT_HOSTPKG_CONFIGURATION:=$(STAGING_DIR_HOSTPKG)/etc/qt6
QT_HOSTPKG_SYSCONF:=$(STAGING_DIR_HOSTPKG)/etc/qt6
QT_HOSTPKG_LIBS:=$(QT_HOSTPKG_PREFIX)/lib
QT_HOSTPKG_DATA:=$(QT_HOSTPKG_PREFIX)/share/qt6
QT_HOSTPKG_HEADERS:=$(QT_HOSTPKG_PREFIX)/include/qt6
QT_HOSTPKG_CMAKES:=$(QT_HOSTPKG_LIBS)/cmake
QT_HOSTPKG_PKGCONFIGS:=$(QT_HOSTPKG_LIBS)/pkgconfig
QT_HOSTPKG_BINS:=$(QT_HOSTPKG_PREFIX)/bin/qt6
QT_HOSTPKG_DOCS:=$(QT_HOSTPKG_DATA)/doc
QT_HOSTPKG_TRANSLATIONS:=$(QT_HOSTPKG_DATA)/translations
QT_HOSTPKG_ARCHDATA:=$(QT_HOSTPKG_LIBS)/qt6
QT_HOSTPKG_MKSPECS:=$(QT_HOSTPKG_ARCHDATA)/mkspecs
QT_HOSTPKG_LIBEXECS:=$(QT_HOSTPKG_ARCHDATA)/libexec
QT_HOSTPKG_TESTS:=$(QT_HOSTPKG_ARCHDATA)/tests
QT_HOSTPKG_PLUGINS:=$(QT_HOSTPKG_ARCHDATA)/plugins
QT_HOSTPKG_METATYPES:=$(QT_HOSTPKG_ARCHDATA)/metatypes
QT_HOSTPKG_IMPORTS:=$(QT_HOSTPKG_ARCHDATA)/imports
QT_HOSTPKG_QML:=$(QT_HOSTPKG_ARCHDATA)/qml
QT_HOSTPKG_EXAMPLES:=$(QT_HOSTPKG_ARCHDATA)/examples
QT_HOSTPKG_DEMOS:=$(QT_HOSTPKG_EXAMPLES)

# for host builds defined in qmake based target project files (STAGING_DIR)/host
# defining here instead of qmake.mk to be available to packages without including qmake.mk
#QT_HOST_PREFIX:=$(STAGING_DIR)/host
QT_HOST_PREFIX:=$(QT_HOSTPKG_PREFIX)
#QT_HOST_DATA:=$(QT_HOST_PREFIX)/share/qt6
QT_HOST_DATA:=$(QT_HOSTPKG_DATA)
#QT_HOST_BINS:=$(QT_HOST_PREFIX)/bin/qt6
QT_HOST_BINS:=$(QT_HOSTPKG_BINS)
#QT_HOST_LIBS:=$(QT_HOST_PREFIX)/lib
QT_HOST_LIBS:=$(QT_HOSTPKG_LIBS)
#QT_HOST_LIBEXECS:=$(QT_HOST_LIBS)/qt6/libexec
QT_HOST_LIBEXECS:=$(QT_HOSTPKG_LIBEXECS)


ifeq (qt, $(firstword $(subst 6, ,$(PKG_NAME))))
# PKG defaults for official Qt modules

PKG_VERSION?=6.9.0

PKG_SOURCE_URL?=https://download.qt.io/official_releases/qt/$(basename $(PKG_VERSION))/$(PKG_VERSION)/submodules
PKG_SYS_NAME?=$(subst -,,$(subst $(firstword $(subst ., ,$(PKG_VERSION))),,$(PKG_NAME)))
PKG_SYS_NAME_FULL?=$(PKG_SYS_NAME)-everywhere-src-$(PKG_VERSION)
PKG_SOURCE?=$(PKG_SYS_NAME_FULL).tar.xz

PKG_LICENSE?=LGPL-3.0-or-commercial

PKG_BUILD_DIR?=$(BUILD_DIR)/$(PKG_SYS_NAME_FULL)
HOST_BUILD_DIR?=$(BUILD_DIR_HOST)/$(PKG_SYS_NAME_FULL)

PKG_BUILD_PARALLEL?=1
HOST_BUILD_PARALLEL?=1
PKG_BUILD_FLAGS?=no-mips16

PKG_INSTALL?=1
endif


define Build/Install/Headers
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_HEADERS)

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_HEADERS)/* \
$(1)/$(QT_INSTALL_HEADERS)/
endef

define Build/Install/Cmakes
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_CMAKES)

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_CMAKES)/* \
$(1)/$(QT_INSTALL_CMAKES)/
endef

define Build/Install/Pkgconfigs
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_PKGCONFIGS)

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_PKGCONFIGS)/* \
$(1)/$(QT_INSTALL_PKGCONFIGS)/
endef

define Build/Install/Libs_shared
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_LIBS)/$(dir $(2))

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_LIBS)/$(2).so* \
$(1)/$(QT_INSTALL_LIBS)/$(dir $(2))/
endef

define Build/Install/Libs_static
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_LIBS)/$(dir $(2))

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_LIBS)/$(2).a \
$(1)/$(QT_INSTALL_LIBS)/$(dir $(2))/
endef

define Build/Install/Libs
$(call Build/Install/Libs_shared,$(1),$(2))
endef

define Build/Install/Archdata
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_ARCHDATA)

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_ARCHDATA)/* \
$(1)/$(QT_INSTALL_ARCHDATA)/
endef

define Build/Install/Data
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_DATA)

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_DATA)/* \
$(1)/$(QT_INSTALL_DATA)/
endef

define Build/Install/Mkspecs
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_MKSPECS)/$(dir $(2))

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_MKSPECS)/$(2) \
$(1)/$(QT_INSTALL_MKSPECS)/$(dir $(2))/
endef

define Build/Install/Metatypes
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_METATYPES)/$(dir $(2))

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_METATYPES)/$(2).json \
$(1)/$(QT_INSTALL_METATYPES)/$(dir $(2))/
endef

define Build/Install/Translations
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_TRANSLATIONS)/$(dir $(2))

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_TRANSLATIONS)/$(2).qm \
$(1)/$(QT_INSTALL_TRANSLATIONS)/$(dir $(2))/
endef

define Build/Install/Plugins
if [ "$(2)" = '*' ]; then \
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_PLUGINS) ; \
$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_PLUGINS)/$(2) \
$(1)/$(QT_INSTALL_PLUGINS)/ ; \
else \
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_PLUGINS)/$(2) ; \
$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_PLUGINS)/$(2)/$(3).so* \
$(1)/$(QT_INSTALL_PLUGINS)/$(2)/ ; \
fi
endef

define Build/Install/Examples
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_EXAMPLES)

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_EXAMPLES)/* \
$(1)/$(QT_INSTALL_EXAMPLES)/

$(FIND) $(1)/$(QT_INSTALL_EXAMPLES) \
-type f \( -name '*.cpp' -o -name '*.h' -o -name '*.pro' -o -name '*.pri' \) | \
$(XARGS) $(RM) -vf
endef

define Build/Install/QMLplugin
$(INSTALL_DIR) \
$(1)/$(QT_INSTALL_QML)/$(2)

$(CP) \
$(PKG_INSTALL_DIR)/$(QT_INSTALL_QML)/$(2)/{plugins.qmltypes,qmldir,$(3).{so,qml,js}} \
$(1)/$(QT_INSTALL_QML)/$(2)/ \
|| true
endef

###

define Build/InstallDev/Qt
$(call Build/Install/Headers,$(1)) || true
$(call Build/Install/Cmakes,$(1)) || true
$(call Build/Install/Pkgconfigs,$(1)) || true
$(call Build/Install/Mkspecs,$(1),*) || true
$(call Build/Install/Libs_shared,$(1),*) || true
$(call Build/Install/Libs_static,$(1),*) || true
$(call Build/Install/Archdata,$(1)) || true
$(call Build/Install/Data,$(1)) || true
endef
122 changes: 122 additions & 0 deletions frameworks/qt6/qmake.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#
# Copyright (C) 2020 OpenWrt.org
# Author: Mirko Vogt <mirko-openwrt@nanl.de>
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

# qmake - oh my.. qmake is supposed to generate Makefiles suitable for cross-compiling
# however fails itself hard being used in a cross compiling toolchain in any sane way.
#
# There are the QT_INSTALL_* variables - which get set via Qt's configure options,
# containing paths which become hardcoded into the qmake binary.
# Those paths are supposed to refer to the target system, however are also used for
# include and linker paths.
# Hence, setting QT_INSTALL_PREFIX=/usr would result in -I/usr/include,
# -L/usr/lib, etc., referencing the host headers and libraries.
# The QT_SYSROOT variable looks most promising for distinguishing between
# host and target specific paths, however it fails hard and is totally undocumented.
# The extprefix variable tries to cover the situation, however actually just prepends
# its path to the QT_INSTALL_* variables - basically cosmetics.
#
# The QT_HOST_* variables are used for host tools, libraries, mkspecs and its data.
#
# As a consequence we set QT_INSTALL_* and QT_HOST_* to absolute paths, which
# inevitably results in the following issues:
#
# - 'make install' results in paths like:
# /tmp/install_root/home/cross/openwrt/staging_dir/target-*/usr.
# This is workarounded by overriding the PKG_INSTALL_DIR, so the Makefiles don't
# have to care about that.
# - Once compiled, qmake's location and its requirements (mkspecs, etc.) are fixed,
# since its absolute paths were hardcoded. No moving around of the toolchain.
# - Those variables might be used for target binaries for some weird reason, so
# paths to the host staging_dir would make it to the target, logically leading to
# errors.
# - Paths might make it into target binaries, thus referencing non-existing
# objects on the target platform. Tihs behaviour wasn't observed so far, however
# one might use the QT_INSTALL_* variables for some weird reason during runtime.


include $(TOPDIR)/rules.mk

QMAKE_SPEC:=linux-openwrt-host-g++
QMAKE_XSPEC:=linux-openwrt-g++

QMAKE_TARGET=$(STAGING_DIR)/host/bin/qt6/qmake # host exe used for target specific builds
QMAKE_HOST=$(QT_HOST_BINS)/qmake # host exe used for host builds

define Build/Configure/Default
TARGET_CROSS="$(TARGET_CROSS)" \
TARGET_CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
TARGET_CXXFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
$(QMAKE_TARGET) \
-o $(PKG_BUILD_DIR)/$(MAKE_PATH)/Makefile \
$(PKG_BUILD_DIR)/$(MAKE_PATH)/$(if $(1),$(1).pro,)
endef

define Host/Configure/Default
$(QMAKE_HOST) \
-o $(HOST_BUILD_DIR)/$(MAKE_PATH)/Makefile \
$(HOST_BUILD_DIR)/$(MAKE_PATH)/$(if $(1),$(1).pro,)
endef

# We need to pass all qmake (TARGET_*) related variables to $(MAKE) as well, as
# (generated) Makefiles may invoke qmake once again for creating further Makefiles.
# Actually we'd also like to pass all other vars (defined in $MAKE_VARS and
# $MAKE_FLAGS) to also make ordinary non-qmake generated Makefiles calling tool-
# chain executables like $CC/$CXX/$AR.. work, however this would interfere with
# qmake generated Makefiles, since they expect variables being set differently.
# For example qmake generated Makefiles expect $AR to also contain ar's arguments,
# while ordinary Makefiles don't.
# Until we find a way to disginguish both kinds of Makefiles, we will neglect
# ordinary Makefiles calling toolchain executables, however as they might take
# $CFLAGS/CXXFLAGS into account (e.g. flags as -D*), we pass at least those
# hoping to not interfere / break something.
# Mixing qmake generated and ordinary Makfiles - both calling toolchain execut-
# ables - is probably a very rare case anyway.
define Build/Compile/Default
+TARGET_CROSS="$(TARGET_CROSS)" \
TARGET_CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
TARGET_CXXFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
CXXFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
$(1)
endef

define Host/Compile/Default
$(MAKE) $(PKG_JOBS) -C $(HOST_BUILD_DIR)/$(MAKE_PATH) \
$(1)
endef

define Build/Install/Default
INSTALL_ROOT="$(PKG_INSTALL_DIR)/.owrttmp" \
$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
$(1) install
mv "$(PKG_INSTALL_DIR)/.owrttmp/$(STAGING_DIR)/"* \
$(PKG_INSTALL_DIR)/ && \
rm -r $(PKG_INSTALL_DIR)/.owrttmp
endef

define Host/Install/Default
INSTALL_ROOT="$(HOST_INSTALL_DIR)/.owrttmp" \
$(MAKE) -C $(HOST_BUILD_DIR)/$(MAKE_PATH) \
$(1) install
mv "$(HOST_INSTALL_DIR)/.owrttmp/$(STAGING_DIR_HOST)/"* \
$(HOST_INSTALL_DIR)/ && \
rm -r "$(HOST_INSTALL_DIR)/.owrttmp"
endef

# target specific host builds triggered by target qmake runs
define Build/Install/HostFiles
$(INSTALL_DIR) \
$(STAGING_DIR)/host

$(CP) \
$(PKG_INSTALL_DIR)/host/* \
$(STAGING_DIR)/host/
endef
6 changes: 6 additions & 0 deletions frameworks/qt6/qt6base/Config_qt6base-core.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config BUILD_qt6base-core_INOTIFY
bool "Use native inotify support on Linux"
depends on PACKAGE_qt6base-core
default y
help
"Compiles Qt's QFileSystemWatcher with support for inotify on Linux. Otherwise QFileSystemWatcher uses polling as fallback."
Loading
Loading