[qt5base] fix path to target qmake
[feed/video.git] / frameworks / qt5base / files / qmake.mk
1 #
2 # Copyright (C) 2015 OpenWrt.org
3 # Author: Mirko Vogt <mirko@openwrt.org>
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 # qmake - oh my.. qmake is supposed to generate Makefiles suitable for cross-compiling
9 # however fails itself hard being used in a cross compiling toolchain in any sane way.
10 #
11 # There are the QT_INSTALL_* variables - which get set via Qt's configure options,
12 # containing paths which become hardcoded into the qmake binary.
13 # Those paths are supposed to refer to the target system, however are also used for
14 # include and linker paths.
15 # Hence, setting QT_INSTALL_PREFIX=/usr would result in -I/usr/include,
16 # -L/usr/lib, etc., referencing the host headers and libraries.
17 # The QT_SYSROOT variable looks most promising for distinguishing between
18 # host and target specific paths, however it fails hard and is totally undocumented.
19 # The extprefix variable tries to cover the situation, however actually just prepends
20 # its path to the QT_INSTALL_* variables - basically cosmetics.
21 #
22 # The QT_HOST_* variables are used for host tools, libraries, mkspecs and its data.
23 #
24 # As a consequence we set QT_INSTALL_* and QT_HOST_* to absolute paths, which
25 # inevitably results in the following issues:
26 #
27 # - 'make install' results in paths like:
28 # /tmp/install_root/home/cross/openwrt/staging_dir/target-*/usr.
29 # This is workarounded by overriding the PKG_INSTALL_DIR, so the Makefiles don't
30 # have to care about that.
31 # - Once compiled, qmake's location and its requirements (mkspecs, etc.) are fixed,
32 # since its absolute paths were hardcoded. No moving around of the toolchain.
33 # - Those variables might be used for target binaries for some weird reason, so
34 # paths to the host staging_dir would make it to the target, logically leading to
35 # errors.
36 # - Paths might make it into target binaries, thus referencing non-existing
37 # objects on the target platform. Tihs behaviour wasn't observed so far, however
38 # one might use the QT_INSTALL_* variables for some weird reason during runtime.
39
40 # for target builds (STAGING_DIR)
41 QT_EXTPREFIX:=$(STAGING_DIR)/$(CONFIGURE_PREFIX)
42 QT_SYSROOT:=
43 QT_INSTALL_CONFIGURATION:=/etc/qt5
44 QT_INSTALL_PREFIX:=$(CONFIGURE_PREFIX)
45 QT_INSTALL_LIBS:=$(QT_INSTALL_PREFIX)/lib
46 QT_INSTALL_DATA:=$(QT_INSTALL_PREFIX)/share/qt5
47 QT_INSTALL_HEADERS:=$(QT_INSTALL_PREFIX)/include
48 QT_INSTALL_BINS:=$(QT_INSTALL_PREFIX)/bin
49 QT_INSTALL_DOCS:=$(QT_INSTALL_DATA)/doc
50 QT_INSTALL_TRANSLATIONS:=$(QT_INSTALL_DATA)/translations
51 QT_INSTALL_ARCHDATA:=$(QT_INSTALL_LIBS)/qt5
52 QT_INSTALL_LIBEXECS:=$(QT_INSTALL_ARCHDATA)
53 QT_INSTALL_TESTS:=$(QT_INSTALL_ARCHDATA)/tests
54 QT_INSTALL_PLUGINS:=$(QT_INSTALL_ARCHDATA)/plugins
55 QT_INSTALL_IMPORTS:=$(QT_INSTALL_ARCHDATA)/imports
56 QT_INSTALL_QML:=$(QT_INSTALL_ARCHDATA)/qml
57 QT_INSTALL_EXAMPLES:=$(QT_INSTALL_ARCHDATA)/examples
58 QT_INSTALL_DEMOS:=$(QT_INSTALL_EXAMPLES)
59 # for host builds defined in target project files (STAGING_DIR)/host
60 QT_HOST_EXTPREFIX:=$(STAGING_DIR)/host
61 QT_HOST_PREFIX:=$(QT_HOST_EXTPREFIX)
62 QT_HOST_DATA:=$(QT_HOST_PREFIX)/share
63 QT_HOST_BINS:=$(QT_HOST_PREFIX)/bin
64 QT_HOST_LIBS:=$(QT_HOST_PREFIX)/lib
65
66 QMAKE_SPEC:=linux-g++
67 QMAKE_XSPEC:=linux-openwrt-g++
68
69 PKG_INSTALL_DIR_ROOT:=$(PKG_INSTALL_DIR)
70 PKG_INSTALL_DIR:=$(PKG_INSTALL_DIR_ROOT)/$(STAGING_DIR)
71
72 # for target independant host builds (STAGING_DIR_HOST)
73 HOST_INSTALL_DIR_ROOT:=$(HOST_INSTALL_DIR)
74 HOST_INSTALL_DIR:=$(HOST_INSTALL_DIR_ROOT)/$(STAGING_DIR_HOST)
75 #HOST_INSTALL_DIR:=$(HOST_INSTALL_DIR_ROOT)/$(STAGING_DIR)
76
77 QMAKE_TARGET=$(STAGING_DIR)/host/bin/qmake
78 QMAKE_HOST=$(STAGING_DIR_HOST)/bin/qmake
79
80 define Build/Configure/Default
81 TARGET_CROSS="$(TARGET_CROSS)" \
82 TARGET_CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
83 TARGET_CXXFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
84 TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
85 $(QMAKE_TARGET) \
86 -o $(PKG_BUILD_DIR)/$(MAKE_PATH)/Makefile \
87 $(PKG_BUILD_DIR)/$(MAKE_PATH)/$(if $(1),$(1).pro,)
88 endef
89
90 define Host/Configure/Default
91 $(QMAKE_HOST) \
92 -o $(HOST_BUILD_DIR)/$(MAKE_PATH)/Makefile \
93 $(HOST_BUILD_DIR)/$(MAKE_PATH)/$(if $(1),$(1).pro,)
94 endef
95
96 # We need to pass all qmake related variables to $(MAKE) as well, as (generated) Makefiles may invoke qmake once again for creating further Makefiles.
97 # Actually we'd also like to pass $MAKE_VARS and $MAKE_FLAGS to also make ordinary non-qmake generated Makefiles calling toolchain executables
98 # like $CC/$CXX/.. work, however this would interfere with qmake generated Makefiles, since they expect variables being set differently.
99 # For example qmake generated Makefiles expect $AR to also contain ar's arguments, while ordinary Makefiles don't.
100 # Until we find a way to disginguish both kinds of Makefiles, we will neglect ordinary Makefiles calling toolchain executables.
101 # Mixing qmake generated and ordinary Makfiles - both calling toolchain executables - is probably a very rare case anyway.
102 define Build/Compile/Default
103 +TARGET_CROSS="$(TARGET_CROSS)" \
104 TARGET_CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
105 TARGET_CXXFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
106 TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
107 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
108 $(1)
109 endef
110
111 define Host/Compile/Default
112 $(MAKE) $(PKG_JOBS) -C $(HOST_BUILD_DIR)/$(MAKE_PATH) \
113 $(1)
114 endef
115
116 define Build/Install/Default
117 INSTALL_ROOT="$(PKG_INSTALL_DIR_ROOT)" \
118 $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
119 $(1) install
120 endef
121
122 define Host/Install/Default
123 INSTALL_ROOT="$(HOST_INSTALL_DIR_ROOT)" \
124 $(MAKE) -C $(HOST_BUILD_DIR)/$(MAKE_PATH) \
125 $(1) install
126 endef
127
128 define Build/Install/HostFiles
129 $(INSTALL_DIR) \
130 $(1)/host
131
132 $(CP) \
133 $(PKG_INSTALL_DIR)/host/* \
134 $(1)/host/
135 endef
136
137 define Build/Install/Headers
138 $(INSTALL_DIR) \
139 $(1)/$(QT_INSTALL_HEADERS)
140
141 $(CP) \
142 $(PKG_INSTALL_DIR)/$(QT_INSTALL_HEADERS)/* \
143 $(1)/$(QT_INSTALL_HEADERS)/
144 endef
145
146 define Build/Install/Libs
147 $(INSTALL_DIR) \
148 $(1)/$(QT_INSTALL_LIBS)
149
150 $(CP) \
151 $(PKG_INSTALL_DIR)/$(QT_INSTALL_LIBS)/$(2).so* \
152 $(1)/$(QT_INSTALL_LIBS)/
153 endef
154
155 define Build/Install/Plugins
156 $(INSTALL_DIR) \
157 $(1)/$(QT_INSTALL_PLUGINS)/$(2)
158
159 $(CP) \
160 $(PKG_INSTALL_DIR)/$(QT_INSTALL_PLUGINS)/$(2)/$(3).so* \
161 $(1)/$(QT_INSTALL_PLUGINS)/$(2)/
162 endef
163
164 define Build/Install/Examples
165 $(INSTALL_DIR) \
166 $(1)/$(QT_INSTALL_EXAMPLES)
167
168 $(CP) \
169 $(PKG_INSTALL_DIR)/$(QT_INSTALL_EXAMPLES)/* \
170 $(1)/$(QT_INSTALL_EXAMPLES)/
171
172 $(FIND) $(1)/$(QT_INSTALL_EXAMPLES) \
173 -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.pro' -o -name '*.pri' \) | \
174 $(XARGS) $(RM) -vf
175 endef