source: trunk/kBuild/units/qt5.kmk@ 3204

Last change on this file since 3204 was 3160, checked in by bird, 7 years ago

kBuild//*.kmk: Use optimized kmk_builtin_append when availble.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.2 KB
Line 
1# $Id: qt5.kmk 3160 2018-03-19 22:39:19Z bird $
2## @file
3# Qt 5 unit.
4#
5
6#
7# Copyright (c) 2008-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
8#
9# This file is part of kBuild.
10#
11# kBuild is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# kBuild is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with kBuild; if not, write to the Free Software
23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24#
25#
26# As a special exception you are granted permission to include this file, via
27# the kmk include directive, as you wish without this in itself causing the
28# resulting makefile, program or whatever to be covered by the GPL license.
29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
33
34
35ifdef UNIT_qt5
36 $(error kBuild: The qt5 unit was included twice!)
37endif
38UNIT_qt5 = qt5
39
40
41if !defined(UNIT_qt3) && !defined(UNIT_qt4)
42 # Add our target properties (same as qt3 & qt4).
43 PROPS_SINGLE += QTTOOL MOCTOOL UICTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE QT_PREFIX
44 PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS LRCFLAGS QT_TRANSLATIONS QT_MOCSRCS QT_MOCHDRS
45endif
46PROPS_SINGLE += RCCTOOL QT_INFIX
47PROPS_ACCUMULATE_R += RCCFLAGS QT_MODULES
48
49
50## @todo use pkg-config?
51
52#
53# The QT5 SDK.
54#
55# This is implemented here rather than in sdks/QT5.kmk to enforce the global USES.
56# It also makes things easier to develop, with fewer files I mean.
57#
58## @todo the SDK might actually not be necessary as it turns out... For now it servers
59# a purpose if the host differs from the target, in theory at least.
60SDK_QT5 = Qt5
61
62# SDK Specific Properties
63# PATH_SDK_QT5 - The general Qt5 root directory.
64# PATH_SDK_QT5_INC - The include directory.
65# PATH_SDK_QT5_LIB.amd64 - The lib directory for AMD64.
66# PATH_SDK_QT5_LIB.x86 - The lib directory for X86.
67# PATH_SDK_QT5_LIB - The lib directory for KBUILD_TARGET.
68ifndef PATH_SDK_QT5
69 PATH_SDK_QT5 := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v5*)))
70 ifeq ($(PATH_SDK_QT5),)
71 # If target == host, try look for Qt in the various platform specific places.
72 ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
73 ifeq ($(KBUILD_TARGET),darwin)
74 PATH_SDK_QT5 := $(patsubst %/Frameworks/QtCore.framework/Versions/5,%,$(firstword $(wildcard /Library/Frameworks/QtCore.framework/Versions/5)))
75 else ifeq ($(KBUILD_TARGET),win)
76 # No idea here yet...
77 else ifeq ($(KBUILD_TARGET),ose)
78 # No port...
79 else
80 # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT5_LIB* stuff if it doesn't work.
81 # Try find the general root of thing by looking for the qt4to5 program, if not found, then look for rcc.
82 PATH_SDK_QT5 := $(patsubst %/bin/qt4to5-qt5,%,$(firstword $(wildcard \
83 /usr/bin/qt4to5-qt5 \
84 /usr/local/bin/qt4to5-qt5 \
85 /usr/qt/5/bin/qt4to5-qt5 \
86 /usr/share/qt5/bin/qt4to5-qt5 \
87 )))
88 ifeq ($(PATH_SDK_QT5),)
89 PATH_SDK_QT5 := $(patsubst %/bin/qt4to5,%,$(firstword $(wildcard \
90 /usr/bin/qt4to5 \
91 /usr/local/bin/qt4to5 \
92 /usr/qt/5/bin/qt4to5 \
93 /usr/share/qt5/bin/qt4to5 \
94 )))
95 endif
96 ifeq ($(PATH_SDK_QT5),)
97 PATH_SDK_QT5 := $(patsubst %/bin/rcc-qt5,%,$(firstword $(wildcard \
98 /usr/bin/rcc-qt5 \
99 /usr/local/bin/rcc-qt5 \
100 /usr/qt/5/bin/rcc-qt5 \
101 /usr/share/qt5/bin/rcc-qt5 \
102 )))
103 endif
104 ifeq ($(PATH_SDK_QT5),)
105 PATH_SDK_QT5 := $(patsubst %/bin/rcc,%,$(firstword $(wildcard \
106 /usr/lib/*/qt5/bin/rcc \
107 /usr/bin/rcc \
108 /usr/local/bin/rcc \
109 /usr/qt/5/bin/rcc \
110 /usr/share/qt5/bin/rcc \
111 )))
112 endif
113 ifneq ($(PATH_SDK_QT5),)
114 export PATH_SDK_QT5
115
116 # Locate the include files. Check for qglobalstatic.h (since 5.1) first.
117 ifeq ($(PATH_SDK_QT5_INC),)
118 PATH_SDK_QT5_INC := $(patsubst %/QtCore/qglobalstatic.h,%,$(firstword $(wildcard \
119 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt5/QtCore/qglobalstatic.h) \
120 $(PATH_SDK_QT5)/include/qt5/QtCore/qglobalstatic.h \
121 /usr/include/qt5/QtCore/qtglobalstatic.h \
122 /usr/local/include/qt5/QtCore/qtglobalstatic.h \
123 $(PATH_SDK_QT5)/include/QtCore/qglobalstatic.h \
124 /usr/include/qt/QtCore/qglobalstatic.h \
125 /usr/local/include/qt/QtCore/qglobalstatic.h \
126 )))
127 ifeq ($(PATH_SDK_QT5_INC),)
128 PATH_SDK_QT5_INC := $(patsubst %/QtCore/qglobal.h,%,$(firstword $(wildcard \
129 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt5/QtCore/qglobal.h) \
130 $(PATH_SDK_QT5)/include/qt5/QtCore/qglobal.h \
131 /usr/include/qt5/QtCore/qtglobal.h \
132 /usr/local/include/qt5/QtCore/qtglobal.h \
133 $(PATH_SDK_QT5)/include/QtCore/qglobal.h \
134 )))
135 endif
136 ifneq ($(PATH_SDK_QT5_INC),)
137 export PATH_SDK_QT5_INC
138 endif
139 endif
140
141 # Now for the libraries (mostly for helping out finding the KBUILD_TARGET libs).
142 ifeq ($(PATH_SDK_QT5_LIB.x86),)
143 PATH_SDK_QT5_LIB.x86 := $(patsubst %/libQt5Core$(SUFF_DLL),%,$(firstword $(wildcard \
144 $(PATH_SDK_QT5)/lib32/libQt5Core$(SUFF_DLL) \
145 $(PATH_SDK_QT5)/lib32/qt5/libQt5Core$(SUFF_DLL) \
146 /usr/lib32/libQt5Core$(SUFF_DLL) \
147 /usr/lib32/qt5/libQt5Core$(SUFF_DLL) \
148 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/lib/$(type)/libQt5Core$(SUFF_DLL)) \
149 /usr/local/lib32/libQt5Core$(SUFF_DLL) \
150 /usr/local/lib32/qt5/libQt5Core$(SUFF_DLL) \
151 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/local/lib/$(type)/libQt5Core$(SUFF_DLL)) \
152 $(PATH_SDK_QT5)/lib/libQt5Core$(SUFF_DLL) \
153 $(PATH_SDK_QT5)/lib/qt5/libQt5Core$(SUFF_DLL) \
154 $(PATH_SDK_QT5)/lib/i386-linux-gnu/libQt5Core$(SUFF_DLL) \
155 )))
156 ifneq ($(PATH_SDK_QT5_LIB.x86),)
157 export PATH_SDK_QT5_LIB.x86
158 endif
159 endif
160 ifeq ($(PATH_SDK_QT5_LIB.amd64),)
161 PATH_SDK_QT5_LIB.amd64 := $(patsubst %/libQt5Core$(SUFF_DLL),%,$(firstword $(wildcard \
162 $(PATH_SDK_QT5)/lib64/libQt5Core$(SUFF_DLL) \
163 $(PATH_SDK_QT5)/lib64/qt5/libQt5Core$(SUFF_DLL) \
164 $(PATH_SDK_QT5)/lib/amd64/libQt5Core$(SUFF_DLL) \
165 /usr/lib64/libQt5Core$(SUFF_DLL) \
166 /usr/lib64/qt5/libQt5Core$(SUFF_DLL) \
167 /usr/lib/amd64/libQt5Core$(SUFF_DLL) \
168 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/lib/$(type)/libQt5Core$(SUFF_DLL)) \
169 /usr/local/lib64/libQt5Core$(SUFF_DLL) \
170 /usr/local/lib64/qt5/libQt5Core$(SUFF_DLL) \
171 /usr/local/lib/amd64/libQt5Core$(SUFF_DLL) \
172 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/local/lib/$(type)/libQt5Core$(SUFF_DLL)) \
173 $(PATH_SDK_QT5)/lib/libQt5Core$(SUFF_DLL) \
174 $(PATH_SDK_QT5)/lib/qt5/libQt5Core$(SUFF_DLL) \
175 $(PATH_SDK_QT5)/lib/x86_64-linux-gnu/libQt5Core$(SUFF_DLL) \
176 )))
177 ifneq ($(PATH_SDK_QT5_LIB.amd64),)
178 export PATH_SDK_QT5_LIB.amd64
179 endif
180 endif
181
182 # And finally, the library path for KBUILD_TARGET.
183 ifeq ($(PATH_SDK_QT5_LIB),)
184 PATH_SDK_QT5_LIB := $(PATH_SDK_QT5_LIB.$(KBUILD_TARGET_ARCH))
185 ifeq ($(PATH_SDK_QT5_LIB),)
186 PATH_SDK_QT5_LIB := $(patsubst %/libQt5Core$(SUFF_DLL),%,$(firstword $(wildcard \
187 $(PATH_SDK_QT5)/lib/libQt5Core$(SUFF_DLL) \
188 $(PATH_SDK_QT5)/lib/qt5/libQt5Core$(SUFF_DLL) \
189 /usr/lib/libQt5Core$(SUFF_DLL) \
190 /usr/lib/qt5/libQt5Core$(SUFF_DLL) \
191 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/lib/$(type)/libQt5Core$(SUFF_DLL)) \
192 /usr/local/lib/libQt5Core$(SUFF_DLL) \
193 /usr/local/lib/qt5/libQt5Core$(SUFF_DLL) \
194 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/local/lib/$(type)/libQt5Core$(SUFF_DLL)) \
195 )))
196 endif
197 ifneq ($(PATH_SDK_QT5_LIB),)
198 export PATH_SDK_QT5_LIB
199 endif
200 endif
201
202 endif
203 endif # Unices
204 endif
205 # Found it?
206 ifeq ($(PATH_SDK_QT5),)
207 $(warning kBuild: Couldn't find the Qt5 headers and libaries...)
208 PATH_SDK_QT5 := $(KBUILD_DEVTOOLS_TRG)/qt/not-found
209 endif
210 endif
211else
212 # Resolve any fancy stuff once and for all.
213 PATH_SDK_QT5 := $(PATH_SDK_QT5)
214endif
215
216# Libraries can be in either Frameworks or lib depending on how you
217# build it on the mac. The .dmg installs into Frameworks but builds into lib.
218ifeq ($(KBUILD_TARGET),darwin)
219 ifndef PATH_SDK_QT5_LIB
220 ifneq ($(wildcard $(PATH_SDK_QT5)/Frameworks),)
221 PATH_SDK_QT5_LIB ?= $(PATH_SDK_QT5)/Frameworks
222 else
223 PATH_SDK_QT5_LIB ?= $(PATH_SDK_QT5)/lib
224 endif
225 endif
226else
227 PATH_SDK_QT5_LIB ?= $(PATH_SDK_QT5)/lib
228 PATH_SDK_QT5_INC ?= $(PATH_SDK_QT5)/include
229endif
230
231# The bits that kBuild picks up.
232# (nothing here)
233
234
235#
236# The QT5 tool.
237#
238# This is implemented here rather than in tools/QT5.kmk to enforce the global USES.
239# It also makes things easier to develop, with fewer files I mean.
240#
241TOOL_QT5 = Qt5
242
243# Tool Specific Properties
244# PATH_TOOL_QT5 - Obsolete.
245# PATH_TOOL_QT5_BIN - The
246# TOOL_QT5_BIN_SUFF -
247if !defined(PATH_TOOL_QT5_BIN) && defined(PATH_TOOL_QT5)
248 PATH_TOOL_QT5_BIN := $(PATH_TOOL_QT5)/bin
249endif
250ifndef PATH_TOOL_QT5_BIN
251 PATH_TOOL_QT5_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST)/qt/v5*/bin)))
252 if "$(PATH_TOOL_QT5_BIN)" == "" && "$(KBUILD_DEVTOOLS_HST_ALT)" != ""
253 PATH_TOOL_QT5_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST_ALT)/qt/v5*/bin)))
254 endif
255 ifeq ($(PATH_TOOL_QT5_BIN),)
256 ifdef TOOL_QT5_BIN_SUFF
257 TOOL_QT5_BIN_SUFF := $(TOOL_QT5_BIN_SUFF)
258 endif
259 # Try looking for moc-qt5 / moc-$(suffix) first.
260 ifneq ($(TOOL_QT5_BIN_SUFF),)
261 PATH_TOOL_QT5_BIN := $(patsubst %/moc$(TOOL_QT5_BIN_SUFF),%,$(firstword $(wildcard \
262 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/moc$(TOOL_QT5_BIN_SUFF)) \
263 /usr/lib/qt5/bin/moc$(TOOL_QT5_BIN_SUFF) \
264 /usr/qt/5/bin/moc$(TOOL_QT5_BIN_SUFF) \
265 /usr/share/qt5/bin/moc$(TOOL_QT5_BIN_SUFF) \
266 /usr/local/bin/moc$(TOOL_QT5_BIN_SUFF) \
267 /usr/bin/moc$(TOOL_QT5_BIN_SUFF) \
268 )))
269 else
270 # No suffix given, so before we check out -qt5 look at qt5 specific locations to avoid choosers and symlinks.
271 PATH_TOOL_QT5_BIN := $(patsubst %/moc,%,$(firstword $(wildcard \
272 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/moc) \
273 $(if $(intersects $(KBUILD_HOST_ARCH), $(KBUILD_ARCHES_64)),/usr/lib64/qt5/bin/moc,) \
274 /usr/lib/qt5/bin/moc \
275 /usr/local/lib/qt5/bin/moc \
276 /usr/qt/5/bin/moc \
277 /usr/local/qt/5/bin/moc \
278 /usr/share/qt5/bin/moc \
279 /usr/local/share/qt5/bin/moc \
280 )))
281 ifeq ($(PATH_TOOL_QT5_BIN),)
282 PATH_TOOL_QT5_BIN := $(patsubst %/moc-qt5,%,$(firstword $(wildcard \
283 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/moc-qt5) \
284 /usr/lib/qt5/bin/moc-qt5 \
285 /usr/qt/5/bin/moc-qt5 \
286 /usr/share/qt5/bin/moc-qt5 \
287 /usr/local/bin/moc-qt5 \
288 /usr/bin/moc-qt5 \
289 )))
290 ifneq ($(PATH_TOOL_QT5_BIN),)
291 TOOL_QT5_BIN_SUFF := -qt5
292 endif
293 endif
294 endif
295 # If still no go, try looking for qt4to5 and rcc.
296 ifeq ($(PATH_TOOL_QT5_BIN),)
297 PATH_TOOL_QT5_BIN := $(patsubst %/qt4to5,%,$(firstword $(wildcard \
298 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/qt4to5) \
299 /usr/lib/qt5/bin/qt4to5 \
300 /usr/qt/5/bin/qt4to5 \
301 /usr/share/qt5/bin/qt4to5 \
302 /usr/local/bin/qt4to5 \
303 /usr/bin/qt4to5 \
304 )))
305 endif
306 ifeq ($(PATH_TOOL_QT5_BIN),)
307 PATH_TOOL_QT5_BIN := $(patsubst %/rcc$(TOOL_QT5_BIN_SUFF),%,$(firstword $(wildcard \
308 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/rcc$(TOOL_QT5_BIN_SUFF)) \
309 /usr/lib/qt5/bin/rcc$(TOOL_QT5_BIN_SUFF) \
310 /usr/qt/5/bin/rcc$(TOOL_QT5_BIN_SUFF) \
311 /usr/share/qt5/bin/rcc$(TOOL_QT5_BIN_SUFF) \
312 /usr/local/bin/rcc$(TOOL_QT5_BIN_SUFF) \
313 /usr/bin/rcc$(TOOL_QT5_BIN_SUFF) \
314 )))
315 endif
316 if "$(PATH_TOOL_QT5_BIN)" == "" && "$(TOOL_QT5_BIN_SUFF)" != ""
317 PATH_TOOL_QT5_BIN := $(patsubst %/rcc,%,$(firstword $(wildcard \
318 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/rcc) \
319 /usr/lib/qt5/bin/rcc \
320 /usr/qt/5/bin/rcc \
321 /usr/share/qt5/bin/rcc \
322 /usr/local/bin/rcc \
323 /usr/bin/rcc \
324 )))
325 endif
326 ifneq ($(PATH_TOOL_QT5_BIN),)
327 export PATH_TOOL_QT5_BIN
328 endif
329 endif
330 # If not found, we'll enter the 'pathless' mode.
331else
332 # Resolve any fancy stuff once and for all.
333 PATH_TOOL_QT5_BIN := $(PATH_TOOL_QT5_BIN)
334endif
335ifneq ($(PATH_TOOL_QT5_BIN),)
336 TOOL_QT5_MOC ?= $(PATH_TOOL_QT5_BIN)/moc$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
337 TOOL_QT5_UIC ?= $(PATH_TOOL_QT5_BIN)/uic$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
338 ifndef TOOL_QT5_RCC
339 TOOL_QT5_RCC := $(PATH_TOOL_QT5_BIN)/rcc$(HOSTSUFF_EXE)
340 ifeq ($(wildcard $(TOOL_QT5_RCC)),)
341 TOOL_QT5_RCC := $(PATH_TOOL_QT5_BIN)/rcc$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
342 endif
343 endif
344 TOOL_QT5_LRC ?= $(PATH_TOOL_QT5_BIN)/lrelease$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
345 TOOL_QT5_LUPDATE ?= $(PATH_TOOL_QT5_BIN)/lupdate$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
346else
347 # Pathless, relies on the environment.
348 TOOL_QT5_MOC ?= moc$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
349 TOOL_QT5_UIC ?= uic$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
350 TOOL_QT5_RCC ?= rcc$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
351 TOOL_QT5_LRC ?= lrelease$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
352 TOOL_QT5_LUPDATE ?= lupdate$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
353endif
354ifdef TOOL_QT5_USE_KSUBMIT
355 ifeq ($(KBUILD_HOST),win)
356 TOOL_QT5_MOC_KSUBMIT ?= kmk_builtin_kSubmit --$(SP)
357 endif
358endif
359
360# General Properties used by kBuild and/or units/qt.kmk
361TOOL_QT5_MOCFLAGS ?=
362TOOL_QT5_MOCINCS ?=
363TOOL_QT5_MOCDEFS ?=
364TOOL_QT5_MOCDEFS.darwin ?= __APPLE__ __GNUC__
365TOOL_QT5_MOCDEFS.solaris ?= __sun
366TOOL_QT5_MOCDEFS.win.amd64 ?= WIN64
367TOOL_QT5_MOCDEFS.win.x86 ?= WIN32
368
369
370## MOC a C++ source file.
371# @param $(target) Normalized main target name.
372# @param $(source) Source filename (relative).
373# @param $(out) Object file name. This shall be (re)created by the compilation.
374# @param $(dep) Dependcy file. This may be (re)created by the compilation.
375# @param $(flags) Flags.
376# @param $(defs) Definitions.
377# @param $(incs) Includes.
378# @param $(outbase) Output basename (full). Use this for list files and such.
379#
380TOOL_QT5_MOC_CPP_DEPEND =
381TOOL_QT5_MOC_CPP_DEPORD =
382TOOL_QT5_MOC_CPP_OUTPUT =
383TOOL_QT5_MOC_CPP_OUTPUT_MAYBE =
384define TOOL_QT5_MOC_CPP_CMDS
385 $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
386 $(flags)\
387 $(addprefix -I, $(incs))\
388 $(addprefix -D, $(defs))\
389 -o $(out)\
390 $(source)
391endef
392
393## MOC a C++ header file.
394# @param $(target) Normalized main target name.
395# @param $(source) Source filename (relative).
396# @param $(out) Object file name. This shall be (re)created by the compilation.
397# @param $(dep) Dependcy file. This may be (re)created by the compilation.
398# @param $(flags) Flags.
399# @param $(defs) Definitions.
400# @param $(incs) Includes.
401# @param $(outbase) Output basename (full). Use this for list files and such.
402#
403TOOL_QT5_MOC_HPP_DEPEND =
404TOOL_QT5_MOC_HPP_DEPORD =
405TOOL_QT5_MOC_HPP_OUTPUT =
406TOOL_QT5_MOC_HPP_OUTPUT_MAYBE =
407define TOOL_QT5_MOC_HPP_CMDS
408 $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
409 $(flags)\
410 $(addprefix -I, $(incs))\
411 $(addprefix -D, $(defs))\
412 -o $(out)\
413 $(source)
414endef
415
416## Compile a Qt user interface file (.ui).
417# @param $(target) Normalized main target name.
418# @param $(source) Source filename (relative).
419# @param $(out) Object file name. This shall be (re)created by the compilation.
420# @param $(dep) Dependcy file. This may be (re)created by the compilation.
421# @param $(flags) Flags.
422# @param $(defs) Definitions.
423# @param $(incs) Includes.
424# @param $(outbase) Output basename (full). Use this for list files and such.
425#
426TOOL_QT5_UIC_UI_DEPEND =
427TOOL_QT5_UIC_UI_DEPORD =
428TOOL_QT5_UIC_UI_OUTPUT =
429TOOL_QT5_UIC_UI_OUTPUT_MAYBE =
430define TOOL_QT5_UIC_UI_CMDS
431 $(QUIET)$(TOOL_QT5_UIC)\
432 $(flags)\
433 -o $(out)\
434 $(source)
435endef
436
437## Compile a Qt resource file (.qrc).
438# @param $(target) Normalized main target name.
439# @param $(source) Source filename (relative).
440# @param $(out) Object file name. This shall be (re)created by the compilation.
441# @param $(dep) Dependcy file. This may be (re)created by the compilation.
442# @param $(flags) Flags.
443# @param $(defs) Definitions.
444# @param $(incs) Includes.
445# @param $(outbase) Output basename (full). Use this for list files and such.
446#
447# @remarks The sed script generating the dependency file is a bit naive.
448TOOL_QT5_RCC_QRC_DEPEND =
449TOOL_QT5_RCC_QRC_DEPORD =
450TOOL_QT5_RCC_QRC_OUTPUT =
451TOOL_QT5_RCC_QRC_OUTPUT_MAYBE =
452define TOOL_QT5_RCC_QRC_CMDS
453 $(QUIET)$(TOOL_QT5_RCC)\
454 $(flags)\
455 -o $(out)\
456 $(source)
457 $(QUIET2)$(APPEND) -n $(dep) '\' \
458 '$(out): \' \
459 '$(source) \'
460 $(QUIET2)$(SED) \
461 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
462 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
463 -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
464 -e 's|$$$$| \\|' \
465 --append $(dep) \
466 $(source)
467 $(QUIET2)$(APPEND) $(dep)
468 $(QUIET2)$(SED) \
469 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
470 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
471 -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
472 -e 's|$$$$|:\n|' \
473 --append $(dep) \
474 $(source)
475 $(QUIET2)$(APPEND) $(dep)
476endef
477
478## Compile a Qt translation file (.ts).
479# @param $(target) Normalized main target name.
480# @param $(source) Source filename (relative).
481# @param $(out) Object file name. This shall be (re)created by the compilation.
482# @param $(dep) Dependcy file. This may be (re)created by the compilation.
483# @param $(flags) Flags.
484# @param $(defs) Definitions.
485# @param $(incs) Includes.
486# @param $(outbase) Output basename (full). Use this for list files and such.
487#
488TOOL_QT5_LRC_TS_DEPEND =
489TOOL_QT5_LRC_TS_DEPORD =
490TOOL_QT5_LRC_TS_OUTPUT =
491TOOL_QT5_LRC_TS_OUTPUT_MAYBE =
492define TOOL_QT5_LRC_TS_CMDS
493 $(QUIET)$(TOOL_QT5_LRC)\
494 $(flags)\
495 $(source)\
496 -qm $(out)
497endef
498
499
500
501#
502#
503# Back to the Qt5 unit.
504#
505#
506
507
508## wrapper for the lrelease (LRC) command dependencies.
509ifndef NO_COMPILE_CMDS_DEPS
510 _UNIT_QT5_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
511else
512 _UNIT_QT5_LRC_CMDS_DEP =
513endif
514
515##
516# def_unit_qt5_target_pre_handle_translation helper that is expanded before evaluation.
517#
518# This is necessary to resolve reference to local variables before doing
519# assignments and setting up commands. They would otherwise be resolved
520# later in a different context and the result would be completely wrong.
521#
522define def_unit_qt5_target_pre_handle_translation_dx
523
524$(out) + $(more_output) +| $(maybe_output): \
525 $(deps) \
526 $(value _UNIT_QT5_LRC_CMDS_DEP) \
527 | \
528 $(orderdeps)
529 %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
530 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
531
532$(cmds)
533
534ifndef NO_COMPILE_CMDS_DEPS
535ifdef KBUILD_HAVE_OPTIMIZED_APPEND
536 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
537 'define $(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_' \
538 '--insert-command=$(out)' \
539 'endef'
540else
541 %$$(QUIET2)$$(APPEND) '$(dep)'
542 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_'
543 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
544 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
545endif
546endif
547
548$(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
549$(target)-inst-nls_SOURCES += $(out)
550
551endef # def_unit_qt5_target_pre_handle_translation_dx
552
553##
554# Handle a source file listed in QT_TRANSLATIONS.
555#
556# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
557# to be translated into .qm files that are loadble by Qt.
558#
559# @remarks Invoked via $(evalvalctx ).
560define def_unit_qt5_target_pre_handle_translation
561local type := LRC
562
563# fetch the properties.
564local tool := $(kb-src-tool dummy_var)
565local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
566local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
567local out := $(outbase).qm
568local dep := $(out).dep
569local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
570local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
571local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
572
573# default path + source dep.
574ifneq ($(defpath),)
575local source := $(abspathex $(source),$(defpath))
576local deps := $(abspathex $(deps),$(defpath)) $(source)
577local incs := $(abspathex $(incs),$(defpath))
578else
579local deps += $(source)
580endif
581
582# call the tool
583ifndef TOOL_$(tool)_LRC_TS_CMDS
584 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
585endif
586local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
587local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
588local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
589local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
590local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
591
592# generate the link rule and update some source and target variables.
593ifndef NO_COMPILE_CMDS_DEPS
594 $(eval includedep $(dep))
595endif
596$(eval $(def_unit_qt5_target_pre_handle_translation_dx))
597
598endef # def_unit_qt5_target_pre_handle_translation
599
600
601
602## wrapper for the UIC command dependencies.
603ifndef NO_COMPILE_CMDS_DEPS
604 _UNIT_QT5_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
605else
606 _UNIT_QT5_RCC_CMDS_DEP =
607endif
608
609##
610# def_unit_qt5_target_pre_handle_qrc helper that is expanded before evaluation.
611#
612# This is necessary to resolve reference to local variables before doing
613# assignments and setting up commands. They would otherwise be resolved
614# later in a different context and the result would be completely wrong.
615#
616define def_unit_qt5_target_pre_handle_rcc_dx
617
618$(out) +| $(realout) $(more_output) $(maybe_output): \
619 $(deps) \
620 $(value _UNIT_QT5_RCC_CMDS_DEP) \
621 | \
622 $(orderdeps)
623 %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
624 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
625
626$(cmds)
627
628 $(QUIET)$(CP) --changed -f $(out) $(realout)
629ifndef NO_COMPILE_CMDS_DEPS
630ifdef KBUILD_HAVE_OPTIMIZED_APPEND
631 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
632 'define $(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_' \
633 '--insert-command=$(out)' \
634 'endef'
635else
636 %$$(QUIET2)$$(APPEND) '$(dep)'
637 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_'
638 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
639 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
640endif
641endif
642
643$(target)_INTERMEDIATES += $(realout)
644$(target)_GEN_SOURCES_ += $(realout)
645$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
646
647endef # def_unit_qt5_target_pre_handle_rcc_dx
648
649##
650# Source handler for .qrc sources (Qt resource files).
651#
652# @remarks $(evalvalctx me).
653define def_unit_qt5_src_handler_qrc
654local type := RCC
655
656# fetch the properties.
657local tool := $(kb-src-tool dummy_var)
658local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
659local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
660local out := $(outbase).tmp.gen.cpp
661local realout := $(outbase).gen.cpp
662local dep := $(realout).dep
663local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
664local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
665local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
666
667# default path + source dep.
668ifneq ($(defpath),)
669local source := $(abspathex $(source),$(defpath))
670local deps := $(abspathex $(deps),$(defpath)) $(source)
671local incs := $(abspathex $(incs),$(defpath))
672else
673local deps += $(source)
674endif
675
676# call the tool
677ifndef TOOL_$(tool)_RCC_QRC_CMDS
678 $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
679endif
680local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
681local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
682local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
683local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
684local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
685
686# generate the link rule and update some source and target variables.
687ifndef NO_COMPILE_CMDS_DEPS
688 $(eval includedep $(dep))
689endif
690$(eval $(def_unit_qt5_target_pre_handle_rcc_dx))
691
692endef # def_unit_qt5_src_handler_qrc
693
694
695
696## wrapper for the UIC command dependencies.
697ifndef NO_COMPILE_CMDS_DEPS
698 _UNIT_QT5_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
699else
700 _UNIT_QT5_UIC_CMDS_DEP =
701endif
702
703##
704# def_unit_qt5_src_handler_ui helper that is expanded before evaluation.
705#
706# This is necessary to resolve reference to local variables before doing
707# assignments and setting up commands. They would otherwise be resolved
708# later in a different context and the result would be completely wrong.
709#
710define def_unit_qt5_target_pre_handle_ui_dx
711
712$(out) +| $(realout) $(more_output) $(maybe_output): \
713 $(deps) \
714 $(value _UNIT_QT5_UIC_CMDS_DEP) \
715 | \
716 $(orderdeps)
717 %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
718 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
719
720$(cmds)
721
722 $(QUIET)$(CP) --changed -f $(out) $(realout)
723ifndef NO_COMPILE_CMDS_DEPS
724ifdef KBUILD_HAVE_OPTIMIZED_APPEND
725 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
726 'define $(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_' \
727 '--insert-command=$(out)' \
728 'endef'
729else
730 %$$(QUIET2)$$(APPEND) '$(dep)'
731 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_'
732 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
733 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
734endif
735endif
736
737$(target)_INTERMEDIATES += $(realout)
738$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
739
740endef # def_unit_qt5_target_pre_handle_ui_dx
741
742##
743# Source handler for .ui sources.
744#
745# @remarks $(evalvalctx me).
746define def_unit_qt5_src_handler_ui
747local type := UIC
748
749# fetch the properties.
750local tool := $(kb-src-tool dummy_var)
751local qtuicdir := $($(target)_0_OUTDIR)/qtuic
752local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
753local out := $(outbase).tmp.gen.h
754local realout := $(outbase).gen.h
755local dep := $(realout).dep
756local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
757local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
758local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
759
760# default path + source dep.
761ifneq ($(defpath),)
762local source := $(abspathex $(source),$(defpath))
763local deps := $(abspathex $(deps),$(defpath)) $(source)
764local incs := $(abspathex $(incs),$(defpath))
765else
766local deps += $(source)
767endif
768
769# call the tool
770ifndef TOOL_$(tool)_UIC_UI_CMDS
771 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
772endif
773local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
774local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
775local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
776local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
777local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
778
779# generate the link rule and update some source and target variables.
780ifndef NO_COMPILE_CMDS_DEPS
781 $(eval includedep $(dep))
782endif
783$(eval $(def_unit_qt5_target_pre_handle_ui_dx))
784
785endef # def_unit_qt5_src_handler_ui
786
787
788
789## wrapper for the MOC command dependencies.
790ifndef NO_COMPILE_CMDS_DEPS
791 _UNIT_QT5_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
792else
793 _UNIT_QT5_MOC_HPP_CMDS_DEP =
794endif
795
796##
797# def_unit_qt5_target_pre_handle_moc_hdr helper that is expanded before evaluation.
798#
799# This is necessary to resolve reference to local variables before doing
800# assignments and setting up commands. They would otherwise be resolved
801# later in a different context and the result would be completely wrong.
802#
803define def_unit_qt5_target_pre_handle_moc_hdr_dx
804
805$(out) +| $(realout) $(more_output) $(maybe_output): \
806 $(deps) \
807 $(value _UNIT_QT5_MOC_HPP_CMDS_DEP) \
808 | \
809 $(orderdeps)
810 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
811 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
812
813$(cmds)
814
815 $(QUIET)$(CP) --changed -f $(out) $(realout)
816ifndef NO_COMPILE_CMDS_DEPS
817ifdef KBUILD_HAVE_OPTIMIZED_APPEND
818 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
819 'define $(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_' \
820 '--insert-command=$(out)' \
821 'endef'
822else
823 %$$(QUIET2)$$(APPEND) '$(dep)'
824 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_'
825 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
826 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
827endif
828endif
829
830$(target)_INTERMEDIATES += $(realout)
831$(target)_GEN_SOURCES_ += $(realout)
832$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
833
834endef
835
836##
837# Handle a source file listed in QT_MOCHDRS.
838#
839# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
840# generate a .cpp file for each of them and add it to the generated
841# sources so that it's compiled and linked. (There is an alternative
842# way to do this where the .cpp file is included, this isn't currently
843# supported by this unit.)
844#
845# @remarks Invoked via $(evalvalctx ).
846define def_unit_qt5_target_pre_handle_moc_hdr
847local type := MOC
848
849# fetch the properties.
850local tool := $(kb-src-tool dummy_var)
851local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
852local out := $(outbase).tmp.cpp
853local realout := $(outbase).cpp
854local dep := $(realout).dep
855local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
856local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
857local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
858local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
859local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
860
861# default path + source dep.
862ifneq ($(defpath),)
863local source := $(abspathex $(source),$(defpath))
864local deps := $(abspathex $(deps),$(defpath)) $(source)
865local incs := $(abspathex $(incs),$(defpath))
866else
867local deps += $(source)
868endif
869
870# call the tool
871ifndef TOOL_$(tool)_MOC_HPP_CMDS
872 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
873endif
874local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
875local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
876local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
877local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
878local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
879
880# generate the link rule and update some source and target variables.
881ifndef NO_COMPILE_CMDS_DEPS
882 $(eval includedep $(dep))
883endif
884$(eval $(def_unit_qt5_target_pre_handle_moc_hdr_dx))
885
886endef # def_unit_qt5_target_pre_handle_moc_hdr
887
888
889## wrapper for the MOC command dependencies.
890ifndef NO_COMPILE_CMDS_DEPS
891 _UNIT_QT5_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
892else
893 _UNIT_QT5_MOC_CPP_CMDS_DEP =
894endif
895
896##
897# def_unit_qt5_target_pre_handle_moc_src helper that is expanded before evaluation.
898#
899# This is necessary to resolve reference to local variables before doing
900# assignments and setting up commands. They would otherwise be resolved
901# later in a different context and the result would be completely wrong.
902#
903define def_unit_qt5_target_pre_handle_moc_src_dx
904
905$(out) +| $(realout) $(more_output) $(maybe_output): \
906 $(deps) \
907 $(value _UNIT_QT5_MOC_CPP_CMDS_DEP) \
908 | \
909 $(orderdeps)
910 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
911 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
912
913$(cmds)
914
915 $(QUIET)$(CP) --changed -f $(out) $(realout)
916ifndef NO_COMPILE_CMDS_DEPS
917ifdef KBUILD_HAVE_OPTIMIZED_APPEND
918 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
919 'define $(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_' \
920 '--insert-command=$(out)' \
921 'endef'
922else
923 %$$(QUIET2)$$(APPEND) '$(dep)'
924 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_'
925 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
926 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
927endif
928endif
929
930$(target)_INTERMEDIATES += $(realout)
931$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
932
933endef
934
935##
936# Handle a source file listed in QT_MOCSRCS.
937#
938# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
939# a .moc file that we're expected to generate here.
940#
941# @remarks Invoked via $(evalvalctx ).
942define def_unit_qt5_target_pre_handle_moc_src
943local type := MOC
944
945# fetch the properties.
946local tool := $(kb-src-tool dummy_var)
947local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
948local out := $(outbase).tmp.moc
949local realout := $(outbase).moc
950local dep := $(realout).dep
951local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
952local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
953local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
954local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
955local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
956
957# default path + source dep.
958ifneq ($(defpath),)
959local source := $(abspathex $(source),$(defpath))
960local deps := $(abspathex $(deps),$(defpath)) $(source)
961local incs := $(abspathex $(incs),$(defpath))
962else
963local deps += $(source)
964endif
965
966# call the tool
967ifndef TOOL_$(tool)_MOC_CPP_CMDS
968 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
969endif
970local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
971local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
972local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
973local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
974local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
975
976# generate the link rule and update some source and target variables.
977ifndef NO_COMPILE_CMDS_DEPS
978 $(eval includedep $(dep))
979endif
980$(eval $(def_unit_qt5_target_pre_handle_moc_src_dx))
981
982endef # def_unit_qt5_target_pre_handle_moc_src
983
984
985##
986# Adds sources containing Q_OBJECT to QT_MOCSRCS.
987define def_unit_qt5_target_pre_cpp_source
988ifneq ($(file-size $(source)),-1)
989 ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
990 $(eval $(target)_QT_MOCSRCS += $(source))
991 endif
992endif
993endef # def_unit_qt5_target_pre_cpp_source
994
995##
996# Invoked early in the processing of a target that uses the Qt unit.
997#
998# It will append the qt source handlers to the target (.h, .ui, .ts,
999# .png, .bmp, .gif).
1000#
1001# It will then check all the C++ sources and check which needs
1002# a .moc files and generate rules and dependencies fofor these
1003#
1004define def_unit_qt5_target_pre
1005
1006# Make QTTOOL the default for the specific Qt tools instead of TOOL.
1007ifneq ($($(target)_QTTOOL),)
1008 ifeq ($($(target)_MOCTOOL),)
1009 $(target)_MOCTOOL := $($(target)_QTTOOL)
1010 endif
1011 ifeq ($($(target)_UICTOOL),)
1012 $(target)_UICTOOL := $($(target)_QTTOOL)
1013 endif
1014 ifeq ($($(target)_RCCTOOL),)
1015 $(target)_RCCTOOL := $($(target)_QTTOOL)
1016 endif
1017 ifeq ($($(target)_LRCTOOL),)
1018 $(target)_LRCTOOL := $($(target)_QTTOOL)
1019 endif
1020endif
1021
1022# Deal with QT_MODULES, QT_PREFIX and QT_INFIX.
1023local qt_modules := \
1024 $($(target)_QT_MODULES.$(bld_trg)) \
1025 $($(target)_QT_MODULES.$(bld_trg_arch)) \
1026 $($(target)_QT_MODULES.$(bld_trg).$(bld_trg_arch)) \
1027 $($(target)_QT_MODULES.$(bld_trg_cpu)) \
1028 $($(target)_QT_MODULES.$(bld_type)) \
1029 $($(target)_QT_MODULES)
1030local qt_prefix := $(firstword \
1031 $($(target)_QT_PREFIX.$(bld_trg)) \
1032 $($(target)_QT_PREFIX.$(bld_trg_arch)) \
1033 $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
1034 $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
1035 $($(target)_QT_PREFIX.$(bld_type)) \
1036 $($(target)_QT_PREFIX))
1037local qt_infix := $(firstword \
1038 $($(target)_QT_INFIX.$(bld_trg)) \
1039 $($(target)_QT_INFIX.$(bld_trg_arch)) \
1040 $($(target)_QT_INFIX.$(bld_trg).$(bld_trg_arch)) \
1041 $($(target)_QT_INFIX.$(bld_trg_cpu)) \
1042 $($(target)_QT_INFIX.$(bld_type)) \
1043 $($(target)_QT_INFIX))
1044ifeq ($(bld_trg),darwin)
1045 # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
1046 $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT5_LIB) )
1047 $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT5_LIB) )
1048 $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT5_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) )
1049 $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/5/Headers) )
1050else
1051 ifeq ($(bld_trg),win)
1052 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_LIB)) )
1053 ifeq ($(tool_do),LINK_PROGRAM)
1054 $(eval $(target)_LIBS += $(PATH_SDK_QT5_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) )
1055 endif
1056 else
1057 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/lib$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_DLL)) )
1058 endif
1059 $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT5_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT5_INC) )
1060endif
1061$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
1062
1063
1064# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
1065# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
1066ifndef $(target)_QT_MOCSRCS
1067 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
1068 $($(target)_SOURCES.$(bld_trg)) \
1069 $($(target)_SOURCES.$(bld_trg_arch)) \
1070 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1071 $($(target)_SOURCES.$(bld_trg_cpu)) \
1072 $($(target)_SOURCES.$(bld_type)) \
1073 $($(target)_SOURCES) \
1074 ), $(evalval def_unit_qt5_target_pre_cpp_source))
1075endif
1076
1077# Install source handlers for .ui files.
1078$(target)_SRC_HANDLERS += \
1079 .ui:def_unit_qt5_src_handler_ui \
1080 .UI:def_unit_qt5_src_handler_ui \
1081 .qrc:def_unit_qt5_src_handler_qrc \
1082 .qrc:def_unit_qt5_src_handler_qrc
1083
1084# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
1085local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
1086local qtuicdir := $($(target)_0_OUTDIR)/qtuic
1087local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
1088local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
1089$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
1090$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
1091
1092# Deal with QT_MOCSRCS.
1093$(foreach source, \
1094 $($(target)_QT_MOCSRCS.$(bld_trg)) \
1095 $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
1096 $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
1097 $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
1098 $($(target)_QT_MOCSRCS.$(bld_type)) \
1099 $($(target)_QT_MOCSRCS) \
1100 , $(evalvalctx def_unit_qt5_target_pre_handle_moc_src))
1101
1102# Deal with QT_MOCHDRS.
1103$(foreach source, \
1104 $($(target)_QT_MOCHDRS.$(bld_trg)) \
1105 $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
1106 $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
1107 $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
1108 $($(target)_QT_MOCHDRS.$(bld_type)) \
1109 $($(target)_QT_MOCHDRS) \
1110 , $(evalvalctx def_unit_qt5_target_pre_handle_moc_hdr))
1111
1112# Deal with QT_TRANSLATIONS.
1113# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
1114local translations := \
1115 $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
1116 $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
1117 $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
1118 $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
1119 $($(target)_QT_TRANSLATIONS.$(bld_type)) \
1120 $($(target)_QT_TRANSLATIONS)
1121ifneq ($(strip $(translations)),)
1122 local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
1123 $(eval $(expr))
1124 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
1125 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
1126 else
1127 $(target)-inst-nls_MODE := 0644
1128 endif
1129 ifdef $(target)_QT_TRANSLATIONS_INST
1130 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
1131 endif
1132 $(target)-inst-nls_SOURCES :=
1133 $(foreach source, $(translations)\
1134 , $(evalvalctx def_unit_qt5_target_pre_handle_translation))
1135endif
1136
1137endef # def_unit_qt5_target_pre
1138
1139
1140#
1141# Rule for debugging.
1142#
1143unit-qt5-show-vars:
1144 @$(ECHO) 'The Qt5 SDK variables:'
1145 @$(ECHO) ' PATH_SDK_QT5 = "$(PATH_SDK_QT5)"'
1146 @$(ECHO) ' PATH_SDK_QT5_INC = "$(PATH_SDK_QT5_INC)"'
1147 @$(ECHO) ' PATH_SDK_QT5_LIB = "$(PATH_SDK_QT5_LIB)"'
1148 @$(ECHO) ' PATH_SDK_QT5_LIB.amd64 = "$(PATH_SDK_QT5_LIB.amd64)"'
1149 @$(ECHO) ' PATH_SDK_QT5_LIB.x86 = "$(PATH_SDK_QT5_LIB.x86)"'
1150 @$(ECHO) 'The Qt5 TOOL variables:'
1151 @$(ECHO) ' PATH_TOOL_QT5_BIN = "$(PATH_TOOL_QT5_BIN)"'
1152 @$(ECHO) ' TOOL_QT5_BIN_SUFF = "$(TOOL_QT5_BIN_SUFF)"'
1153 @$(ECHO) ' TOOL_QT5_MOC = "$(TOOL_QT5_MOC)"'
1154 @$(ECHO) ' TOOL_QT5_UIC = "$(TOOL_QT5_UIC)"'
1155 @$(ECHO) ' TOOL_QT5_RCC = "$(TOOL_QT5_RCC)"'
1156 @$(ECHO) ' TOOL_QT5_LRC = "$(TOOL_QT5_LRC)"'
1157 @$(ECHO) ' TOOL_QT5_LUPDATE = "$(TOOL_QT5_LUPDATE)"'
1158
Note: See TracBrowser for help on using the repository browser.