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

Last change on this file since 3669 was 3349, checked in by bird, 5 years ago

units/qt5.kmk: Fixed inverted quoting check in the qrc/rcc handling. Change to check for KMK_WITH_QUOTING rather than scan KMK_FEATURES all the time.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.0 KB
Line 
1# $Id: qt5.kmk 3349 2020-05-23 09:54: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 =
384ifdef KMK_WITH_QUOTING
385 define TOOL_QT5_MOC_CPP_CMDS
386 $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
387 $(flags)\
388 $(qaddprefix sh,-I, $(incs))\
389 $(qaddprefix sh,-D, $(defs))\
390 -o $(out)\
391 $(source)
392 endef
393else
394 define TOOL_QT5_MOC_CPP_CMDS
395 $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
396 $(flags)\
397 $(addprefix -I, $(incs))\
398 $(addprefix -D, $(defs))\
399 -o $(out)\
400 $(source)
401 endef
402endif
403
404## MOC a C++ header file.
405# @param $(target) Normalized main target name.
406# @param $(source) Source filename (relative).
407# @param $(out) Object file name. This shall be (re)created by the compilation.
408# @param $(dep) Dependcy file. This may be (re)created by the compilation.
409# @param $(flags) Flags.
410# @param $(defs) Definitions.
411# @param $(incs) Includes.
412# @param $(outbase) Output basename (full). Use this for list files and such.
413#
414TOOL_QT5_MOC_HPP_DEPEND =
415TOOL_QT5_MOC_HPP_DEPORD =
416TOOL_QT5_MOC_HPP_OUTPUT =
417TOOL_QT5_MOC_HPP_OUTPUT_MAYBE =
418ifdef KMK_WITH_QUOTING
419 define TOOL_QT5_MOC_HPP_CMDS
420 $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
421 $(flags)\
422 $(qaddprefix sh,-I, $(incs))\
423 $(qaddprefix sh,-D, $(defs))\
424 -o $(out)\
425 $(source)
426 endef
427else
428 define TOOL_QT5_MOC_HPP_CMDS
429 $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
430 $(flags)\
431 $(addprefix -I, $(incs))\
432 $(addprefix -D, $(defs))\
433 -o $(out)\
434 $(source)
435 endef
436endif
437
438## Compile a Qt user interface file (.ui).
439# @param $(target) Normalized main target name.
440# @param $(source) Source filename (relative).
441# @param $(out) Object file name. This shall be (re)created by the compilation.
442# @param $(dep) Dependcy file. This may be (re)created by the compilation.
443# @param $(flags) Flags.
444# @param $(defs) Definitions.
445# @param $(incs) Includes.
446# @param $(outbase) Output basename (full). Use this for list files and such.
447#
448TOOL_QT5_UIC_UI_DEPEND =
449TOOL_QT5_UIC_UI_DEPORD =
450TOOL_QT5_UIC_UI_OUTPUT =
451TOOL_QT5_UIC_UI_OUTPUT_MAYBE =
452define TOOL_QT5_UIC_UI_CMDS
453 $(QUIET)$(TOOL_QT5_UIC)\
454 $(flags)\
455 -o $(out)\
456 $(source)
457endef
458
459## Compile a Qt resource file (.qrc).
460# @param $(target) Normalized main target name.
461# @param $(source) Source filename (relative).
462# @param $(out) Object file name. This shall be (re)created by the compilation.
463# @param $(dep) Dependcy file. This may be (re)created by the compilation.
464# @param $(flags) Flags.
465# @param $(defs) Definitions.
466# @param $(incs) Includes.
467# @param $(outbase) Output basename (full). Use this for list files and such.
468#
469# @remarks The sed script generating the dependency file is a bit naive.
470TOOL_QT5_RCC_QRC_DEPEND =
471TOOL_QT5_RCC_QRC_DEPORD =
472TOOL_QT5_RCC_QRC_OUTPUT =
473TOOL_QT5_RCC_QRC_OUTPUT_MAYBE =
474define TOOL_QT5_RCC_QRC_CMDS
475 $(QUIET)$(TOOL_QT5_RCC)\
476 $(flags)\
477 -o $(out)\
478 $(source)
479 $(QUIET2)$(APPEND) -n $(dep) '\' \
480 '$(out): \' \
481 '$(source) \'
482 $(QUIET2)$(SED) \
483 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
484 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
485 -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
486 -e 's|$$$$| \\|' \
487 --append $(dep) \
488 $(source)
489 $(QUIET2)$(APPEND) $(dep)
490 $(QUIET2)$(SED) \
491 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
492 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
493 -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
494 -e 's|$$$$|:\n|' \
495 --append $(dep) \
496 $(source)
497 $(QUIET2)$(APPEND) $(dep)
498endef
499
500## Compile a Qt translation file (.ts).
501# @param $(target) Normalized main target name.
502# @param $(source) Source filename (relative).
503# @param $(out) Object file name. This shall be (re)created by the compilation.
504# @param $(dep) Dependcy file. This may be (re)created by the compilation.
505# @param $(flags) Flags.
506# @param $(defs) Definitions.
507# @param $(incs) Includes.
508# @param $(outbase) Output basename (full). Use this for list files and such.
509#
510TOOL_QT5_LRC_TS_DEPEND =
511TOOL_QT5_LRC_TS_DEPORD =
512TOOL_QT5_LRC_TS_OUTPUT =
513TOOL_QT5_LRC_TS_OUTPUT_MAYBE =
514define TOOL_QT5_LRC_TS_CMDS
515 $(QUIET)$(TOOL_QT5_LRC)\
516 $(flags)\
517 $(source)\
518 -qm $(out)
519endef
520
521
522
523#
524#
525# Back to the Qt5 unit.
526#
527#
528
529
530## wrapper for the lrelease (LRC) command dependencies.
531ifndef NO_COMPILE_CMDS_DEPS
532 _UNIT_QT5_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
533else
534 _UNIT_QT5_LRC_CMDS_DEP =
535endif
536
537##
538# def_unit_qt5_target_pre_handle_translation helper that is expanded before evaluation.
539#
540# This is necessary to resolve reference to local variables before doing
541# assignments and setting up commands. They would otherwise be resolved
542# later in a different context and the result would be completely wrong.
543#
544define def_unit_qt5_target_pre_handle_translation_dx
545
546$(out) + $(more_output) +| $(maybe_output): \
547 $(deps) \
548 $(value _UNIT_QT5_LRC_CMDS_DEP) \
549 | \
550 $(orderdeps)
551 %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
552 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
553
554$(cmds)
555
556ifndef NO_COMPILE_CMDS_DEPS
557ifdef KBUILD_HAVE_OPTIMIZED_APPEND
558 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
559 'define $(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_' \
560 '--insert-command=$(out)' \
561 'endef'
562else
563 %$$(QUIET2)$$(APPEND) '$(dep)'
564 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_'
565 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
566 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
567endif
568endif
569
570$(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
571$(target)-inst-nls_SOURCES += $(out)
572
573endef # def_unit_qt5_target_pre_handle_translation_dx
574
575##
576# Handle a source file listed in QT_TRANSLATIONS.
577#
578# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
579# to be translated into .qm files that are loadble by Qt.
580#
581# @remarks Invoked via $(evalvalctx ).
582define def_unit_qt5_target_pre_handle_translation
583local type := LRC
584
585# fetch the properties.
586local tool := $(kb-src-tool dummy_var)
587local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
588local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
589local out := $(outbase).qm
590local dep := $(out).dep
591local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
592local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
593local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
594
595# default path + source dep.
596ifneq ($(defpath),)
597 ifdef KMK_WITH_QUOTING
598local source := $(qabspathex ,$(source),$(defpath))
599local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
600local incs := $(qabspathex ,$(incs),$(defpath))
601 else
602local source := $(abspathex $(source),$(defpath))
603local deps := $(abspathex $(deps),$(defpath)) $(source)
604local incs := $(abspathex $(incs),$(defpath))
605 endif
606else
607local deps += $(source)
608endif
609
610# call the tool
611ifndef TOOL_$(tool)_LRC_TS_CMDS
612 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
613endif
614local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
615local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
616local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
617local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
618local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
619
620# generate the link rule and update some source and target variables.
621ifndef NO_COMPILE_CMDS_DEPS
622 $(eval includedep $(dep))
623endif
624$(eval $(def_unit_qt5_target_pre_handle_translation_dx))
625
626endef # def_unit_qt5_target_pre_handle_translation
627
628
629
630## wrapper for the UIC command dependencies.
631ifndef NO_COMPILE_CMDS_DEPS
632 _UNIT_QT5_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
633else
634 _UNIT_QT5_RCC_CMDS_DEP =
635endif
636
637##
638# def_unit_qt5_target_pre_handle_qrc helper that is expanded before evaluation.
639#
640# This is necessary to resolve reference to local variables before doing
641# assignments and setting up commands. They would otherwise be resolved
642# later in a different context and the result would be completely wrong.
643#
644define def_unit_qt5_target_pre_handle_rcc_dx
645
646$(out) +| $(realout) $(more_output) $(maybe_output): \
647 $(deps) \
648 $(value _UNIT_QT5_RCC_CMDS_DEP) \
649 | \
650 $(orderdeps)
651 %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
652 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
653
654$(cmds)
655
656 $(QUIET)$(CP) --changed -f $(out) $(realout)
657ifndef NO_COMPILE_CMDS_DEPS
658ifdef KBUILD_HAVE_OPTIMIZED_APPEND
659 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
660 'define $(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_' \
661 '--insert-command=$(out)' \
662 'endef'
663else
664 %$$(QUIET2)$$(APPEND) '$(dep)'
665 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_'
666 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
667 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
668endif
669endif
670
671$(target)_2_INTERMEDIATES += $(realout)
672$(target)_GEN_SOURCES_ += $(realout)
673$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
674
675endef # def_unit_qt5_target_pre_handle_rcc_dx
676
677##
678# Source handler for .qrc sources (Qt resource files).
679#
680# @remarks $(evalvalctx me).
681define def_unit_qt5_src_handler_qrc
682local type := RCC
683
684# fetch the properties.
685local tool := $(kb-src-tool dummy_var)
686local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
687local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
688local out := $(outbase).tmp.gen.cpp
689local realout := $(outbase).gen.cpp
690local dep := $(realout).dep
691local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
692local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
693local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
694
695# default path + source dep.
696ifneq ($(defpath),)
697 ifdef KMK_WITH_QUOTING
698local source := $(qabspathex ,$(source),$(defpath))
699local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
700local incs := $(qabspathex ,$(incs),$(defpath))
701 else
702local source := $(abspathex $(source),$(defpath))
703local deps := $(abspathex $(deps),$(defpath)) $(source)
704local incs := $(abspathex $(incs),$(defpath))
705 endif
706else
707local deps += $(source)
708endif
709
710# call the tool
711ifndef TOOL_$(tool)_RCC_QRC_CMDS
712 $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
713endif
714local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
715local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
716local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
717local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
718local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
719
720# generate the link rule and update some source and target variables.
721ifndef NO_COMPILE_CMDS_DEPS
722 $(eval includedep $(dep))
723endif
724$(eval $(def_unit_qt5_target_pre_handle_rcc_dx))
725
726endef # def_unit_qt5_src_handler_qrc
727
728
729
730## wrapper for the UIC command dependencies.
731ifndef NO_COMPILE_CMDS_DEPS
732 _UNIT_QT5_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
733else
734 _UNIT_QT5_UIC_CMDS_DEP =
735endif
736
737##
738# def_unit_qt5_src_handler_ui helper that is expanded before evaluation.
739#
740# This is necessary to resolve reference to local variables before doing
741# assignments and setting up commands. They would otherwise be resolved
742# later in a different context and the result would be completely wrong.
743#
744define def_unit_qt5_target_pre_handle_ui_dx
745
746$(out) +| $(realout) $(more_output) $(maybe_output): \
747 $(deps) \
748 $(value _UNIT_QT5_UIC_CMDS_DEP) \
749 | \
750 $(orderdeps)
751 %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
752 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
753
754$(cmds)
755
756 $(QUIET)$(CP) --changed -f $(out) $(realout)
757ifndef NO_COMPILE_CMDS_DEPS
758ifdef KBUILD_HAVE_OPTIMIZED_APPEND
759 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
760 'define $(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_' \
761 '--insert-command=$(out)' \
762 'endef'
763else
764 %$$(QUIET2)$$(APPEND) '$(dep)'
765 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_'
766 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
767 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
768endif
769endif
770
771$(target)_2_INTERMEDIATES += $(realout)
772$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
773
774endef # def_unit_qt5_target_pre_handle_ui_dx
775
776##
777# Source handler for .ui sources.
778#
779# @remarks $(evalvalctx me).
780define def_unit_qt5_src_handler_ui
781local type := UIC
782
783# fetch the properties.
784local tool := $(kb-src-tool dummy_var)
785local qtuicdir := $($(target)_0_OUTDIR)/qtuic
786local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
787local out := $(outbase).tmp.gen.h
788local realout := $(outbase).gen.h
789local dep := $(realout).dep
790local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
791local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
792local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
793
794# default path + source dep.
795ifneq ($(defpath),)
796 ifdef KMK_WITH_QUOTING
797local source := $(qabspathex ,$(source),$(defpath))
798local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
799local incs := $(qabspathex ,$(incs),$(defpath))
800 else
801local source := $(abspathex $(source),$(defpath))
802local deps := $(abspathex $(deps),$(defpath)) $(source)
803local incs := $(abspathex $(incs),$(defpath))
804 endif
805else
806local deps += $(source)
807endif
808
809# call the tool
810ifndef TOOL_$(tool)_UIC_UI_CMDS
811 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
812endif
813local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
814local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
815local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
816local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
817local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
818
819# generate the link rule and update some source and target variables.
820ifndef NO_COMPILE_CMDS_DEPS
821 $(eval includedep $(dep))
822endif
823$(eval $(def_unit_qt5_target_pre_handle_ui_dx))
824
825endef # def_unit_qt5_src_handler_ui
826
827
828
829## wrapper for the MOC command dependencies.
830ifndef NO_COMPILE_CMDS_DEPS
831 _UNIT_QT5_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
832else
833 _UNIT_QT5_MOC_HPP_CMDS_DEP =
834endif
835
836##
837# def_unit_qt5_target_pre_handle_moc_hdr helper that is expanded before evaluation.
838#
839# This is necessary to resolve reference to local variables before doing
840# assignments and setting up commands. They would otherwise be resolved
841# later in a different context and the result would be completely wrong.
842#
843define def_unit_qt5_target_pre_handle_moc_hdr_dx
844
845$(out) +| $(realout) $(more_output) $(maybe_output): \
846 $(deps) \
847 $(value _UNIT_QT5_MOC_HPP_CMDS_DEP) \
848 | \
849 $(orderdeps) $(my_target_intermediate_vars)
850 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
851 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
852
853$(cmds)
854
855 $(QUIET)$(CP) --changed -f $(out) $(realout)
856ifndef NO_COMPILE_CMDS_DEPS
857ifdef KBUILD_HAVE_OPTIMIZED_APPEND
858 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
859 'define $(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_' \
860 '--insert-command=$(out)' \
861 'endef'
862else
863 %$$(QUIET2)$$(APPEND) '$(dep)'
864 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_'
865 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
866 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
867endif
868endif
869
870$(target)_2_INTERMEDIATES += $(realout)
871$(target)_GEN_SOURCES_ += $(realout)
872$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
873
874endef
875
876##
877# Handle a source file listed in QT_MOCHDRS.
878#
879# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
880# generate a .cpp file for each of them and add it to the generated
881# sources so that it's compiled and linked. (There is an alternative
882# way to do this where the .cpp file is included, this isn't currently
883# supported by this unit.)
884#
885# @remarks Invoked via $(evalvalctx ).
886define def_unit_qt5_target_pre_handle_moc_hdr
887local type := MOC
888
889# fetch the properties.
890local tool := $(kb-src-tool dummy_var)
891local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
892local out := $(outbase).tmp.cpp
893local realout := $(outbase).cpp
894local dep := $(realout).dep
895local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
896local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
897local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
898local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
899local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
900
901# default path + source dep.
902ifneq ($(defpath),)
903 ifdef KMK_WITH_QUOTING
904local source := $(qabspathex ,$(source),$(defpath))
905local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
906local incs := $(qabspathex ,$(incs),$(defpath))
907 else
908local source := $(abspathex $(source),$(defpath))
909local deps := $(abspathex $(deps),$(defpath)) $(source)
910local incs := $(abspathex $(incs),$(defpath))
911 endif
912else
913local deps += $(source)
914endif
915
916# call the tool
917ifndef TOOL_$(tool)_MOC_HPP_CMDS
918 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
919endif
920local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
921local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
922local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
923local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
924local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
925
926# generate the link rule and update some source and target variables.
927ifndef NO_COMPILE_CMDS_DEPS
928 $(eval includedep $(dep))
929endif
930$(eval $(def_unit_qt5_target_pre_handle_moc_hdr_dx))
931
932endef # def_unit_qt5_target_pre_handle_moc_hdr
933
934
935## wrapper for the MOC command dependencies.
936ifndef NO_COMPILE_CMDS_DEPS
937 _UNIT_QT5_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
938else
939 _UNIT_QT5_MOC_CPP_CMDS_DEP =
940endif
941
942##
943# def_unit_qt5_target_pre_handle_moc_src helper that is expanded before evaluation.
944#
945# This is necessary to resolve reference to local variables before doing
946# assignments and setting up commands. They would otherwise be resolved
947# later in a different context and the result would be completely wrong.
948#
949define def_unit_qt5_target_pre_handle_moc_src_dx
950
951$(out) +| $(realout) $(more_output) $(maybe_output): \
952 $(deps) \
953 $(value _UNIT_QT5_MOC_CPP_CMDS_DEP) \
954 | \
955 $(orderdeps) $(my_target_intermediate_vars)
956 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
957 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
958
959$(cmds)
960
961 $(QUIET)$(CP) --changed -f $(out) $(realout)
962ifndef NO_COMPILE_CMDS_DEPS
963ifdef KBUILD_HAVE_OPTIMIZED_APPEND
964 %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
965 'define $(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_' \
966 '--insert-command=$(out)' \
967 'endef'
968else
969 %$$(QUIET2)$$(APPEND) '$(dep)'
970 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_'
971 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
972 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
973endif
974endif
975
976$(target)_2_INTERMEDIATES += $(realout)
977$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
978
979endef
980
981##
982# Handle a source file listed in QT_MOCSRCS.
983#
984# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
985# a .moc file that we're expected to generate here.
986#
987# @remarks Invoked via $(evalvalctx ).
988define def_unit_qt5_target_pre_handle_moc_src
989local type := MOC
990
991# fetch the properties.
992local tool := $(kb-src-tool dummy_var)
993local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
994local out := $(outbase).tmp.moc
995local realout := $(outbase).moc
996local dep := $(realout).dep
997local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
998local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
999local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
1000local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
1001local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
1002
1003# default path + source dep.
1004ifneq ($(defpath),)
1005 ifdef KMK_WITH_QUOTING
1006local source := $(qabspathex ,$(source),$(defpath))
1007local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
1008local incs := $(qabspathex ,$(incs),$(defpath))
1009 else
1010local source := $(abspathex $(source),$(defpath))
1011local deps := $(abspathex $(deps),$(defpath)) $(source)
1012local incs := $(abspathex $(incs),$(defpath))
1013 endif
1014else
1015local deps += $(source)
1016endif
1017
1018# call the tool
1019ifndef TOOL_$(tool)_MOC_CPP_CMDS
1020 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
1021endif
1022local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
1023local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
1024local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
1025local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
1026local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
1027
1028# generate the link rule and update some source and target variables.
1029ifndef NO_COMPILE_CMDS_DEPS
1030 $(eval includedep $(dep))
1031endif
1032$(eval $(def_unit_qt5_target_pre_handle_moc_src_dx))
1033
1034endef # def_unit_qt5_target_pre_handle_moc_src
1035
1036
1037##
1038# Adds sources containing Q_OBJECT to QT_MOCSRCS.
1039define def_unit_qt5_target_pre_cpp_source
1040ifneq ($(file-size $(source)),-1)
1041 ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
1042 $(eval $(target)_QT_MOCSRCS += $(source))
1043 endif
1044endif
1045endef # def_unit_qt5_target_pre_cpp_source
1046
1047##
1048# Invoked early in the processing of a target that uses the Qt unit.
1049#
1050# It will append the qt source handlers to the target (.h, .ui, .ts,
1051# .png, .bmp, .gif).
1052#
1053# It will then check all the C++ sources and check which needs
1054# a .moc files and generate rules and dependencies fofor these
1055#
1056define def_unit_qt5_target_pre
1057
1058# Make QTTOOL the default for the specific Qt tools instead of TOOL.
1059ifneq ($($(target)_QTTOOL),)
1060 ifeq ($($(target)_MOCTOOL),)
1061 $(target)_MOCTOOL := $($(target)_QTTOOL)
1062 endif
1063 ifeq ($($(target)_UICTOOL),)
1064 $(target)_UICTOOL := $($(target)_QTTOOL)
1065 endif
1066 ifeq ($($(target)_RCCTOOL),)
1067 $(target)_RCCTOOL := $($(target)_QTTOOL)
1068 endif
1069 ifeq ($($(target)_LRCTOOL),)
1070 $(target)_LRCTOOL := $($(target)_QTTOOL)
1071 endif
1072endif
1073
1074# Deal with QT_MODULES, QT_PREFIX and QT_INFIX.
1075local qt_modules := \
1076 $($(target)_QT_MODULES.$(bld_trg)) \
1077 $($(target)_QT_MODULES.$(bld_trg_arch)) \
1078 $($(target)_QT_MODULES.$(bld_trg).$(bld_trg_arch)) \
1079 $($(target)_QT_MODULES.$(bld_trg_cpu)) \
1080 $($(target)_QT_MODULES.$(bld_type)) \
1081 $($(target)_QT_MODULES)
1082local qt_prefix := $(firstword \
1083 $($(target)_QT_PREFIX.$(bld_trg)) \
1084 $($(target)_QT_PREFIX.$(bld_trg_arch)) \
1085 $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
1086 $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
1087 $($(target)_QT_PREFIX.$(bld_type)) \
1088 $($(target)_QT_PREFIX))
1089local qt_infix := $(firstword \
1090 $($(target)_QT_INFIX.$(bld_trg)) \
1091 $($(target)_QT_INFIX.$(bld_trg_arch)) \
1092 $($(target)_QT_INFIX.$(bld_trg).$(bld_trg_arch)) \
1093 $($(target)_QT_INFIX.$(bld_trg_cpu)) \
1094 $($(target)_QT_INFIX.$(bld_type)) \
1095 $($(target)_QT_INFIX))
1096ifeq ($(bld_trg),darwin)
1097 # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
1098 $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT5_LIB) )
1099 $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT5_LIB) )
1100 $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT5_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) )
1101 $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/5/Headers) )
1102else
1103 ifeq ($(bld_trg),win)
1104 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_LIB)) )
1105 ifeq ($(tool_do),LINK_PROGRAM)
1106 $(eval $(target)_LIBS += $(PATH_SDK_QT5_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) )
1107 endif
1108 else
1109 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/lib$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_DLL)) )
1110 endif
1111 $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT5_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT5_INC) )
1112endif
1113$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
1114
1115
1116# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
1117# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
1118ifndef $(target)_QT_MOCSRCS
1119 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
1120 $($(target)_SOURCES.$(bld_trg)) \
1121 $($(target)_SOURCES.$(bld_trg_arch)) \
1122 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1123 $($(target)_SOURCES.$(bld_trg_cpu)) \
1124 $($(target)_SOURCES.$(bld_type)) \
1125 $($(target)_SOURCES) \
1126 ), $(evalval def_unit_qt5_target_pre_cpp_source))
1127endif
1128
1129# Install source handlers for .ui files.
1130$(target)_SRC_HANDLERS += \
1131 .ui:def_unit_qt5_src_handler_ui \
1132 .UI:def_unit_qt5_src_handler_ui \
1133 .qrc:def_unit_qt5_src_handler_qrc \
1134 .qrc:def_unit_qt5_src_handler_qrc
1135
1136# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
1137local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
1138local qtuicdir := $($(target)_0_OUTDIR)/qtuic
1139local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
1140local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
1141$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
1142$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
1143
1144# Since we add a lot of stuff to 2_INTERMEDIATES, we must exclude it from the intermediates
1145# used by the rules we generate to avoid circular dependencies.
1146local my_target_intermediate_vars := $(filter-out %_2_INTERMEDIATES$(CLOSEPAR),$(target_intermediate_vars))
1147
1148# Deal with QT_MOCSRCS.
1149$(foreach source, \
1150 $($(target)_QT_MOCSRCS.$(bld_trg)) \
1151 $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
1152 $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
1153 $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
1154 $($(target)_QT_MOCSRCS.$(bld_type)) \
1155 $($(target)_QT_MOCSRCS) \
1156 , $(evalvalctx def_unit_qt5_target_pre_handle_moc_src))
1157
1158# Deal with QT_MOCHDRS.
1159$(foreach source, \
1160 $($(target)_QT_MOCHDRS.$(bld_trg)) \
1161 $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
1162 $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
1163 $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
1164 $($(target)_QT_MOCHDRS.$(bld_type)) \
1165 $($(target)_QT_MOCHDRS) \
1166 , $(evalvalctx def_unit_qt5_target_pre_handle_moc_hdr))
1167
1168# Deal with QT_TRANSLATIONS.
1169# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
1170local translations := \
1171 $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
1172 $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
1173 $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
1174 $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
1175 $($(target)_QT_TRANSLATIONS.$(bld_type)) \
1176 $($(target)_QT_TRANSLATIONS)
1177ifneq ($(strip $(translations)),)
1178 local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
1179 $(eval $(expr))
1180 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
1181 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
1182 else
1183 $(target)-inst-nls_MODE := 0644
1184 endif
1185 ifdef $(target)_QT_TRANSLATIONS_INST
1186 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
1187 endif
1188 $(target)-inst-nls_SOURCES :=
1189 $(foreach source, $(translations)\
1190 , $(evalvalctx def_unit_qt5_target_pre_handle_translation))
1191endif
1192
1193endef # def_unit_qt5_target_pre
1194
1195
1196#
1197# Rule for debugging.
1198#
1199unit-qt5-show-vars:
1200 @$(ECHO) 'The Qt5 SDK variables:'
1201 @$(ECHO) ' PATH_SDK_QT5 = "$(PATH_SDK_QT5)"'
1202 @$(ECHO) ' PATH_SDK_QT5_INC = "$(PATH_SDK_QT5_INC)"'
1203 @$(ECHO) ' PATH_SDK_QT5_LIB = "$(PATH_SDK_QT5_LIB)"'
1204 @$(ECHO) ' PATH_SDK_QT5_LIB.amd64 = "$(PATH_SDK_QT5_LIB.amd64)"'
1205 @$(ECHO) ' PATH_SDK_QT5_LIB.x86 = "$(PATH_SDK_QT5_LIB.x86)"'
1206 @$(ECHO) 'The Qt5 TOOL variables:'
1207 @$(ECHO) ' PATH_TOOL_QT5_BIN = "$(PATH_TOOL_QT5_BIN)"'
1208 @$(ECHO) ' TOOL_QT5_BIN_SUFF = "$(TOOL_QT5_BIN_SUFF)"'
1209 @$(ECHO) ' TOOL_QT5_MOC = "$(TOOL_QT5_MOC)"'
1210 @$(ECHO) ' TOOL_QT5_UIC = "$(TOOL_QT5_UIC)"'
1211 @$(ECHO) ' TOOL_QT5_RCC = "$(TOOL_QT5_RCC)"'
1212 @$(ECHO) ' TOOL_QT5_LRC = "$(TOOL_QT5_LRC)"'
1213 @$(ECHO) ' TOOL_QT5_LUPDATE = "$(TOOL_QT5_LUPDATE)"'
1214
Note: See TracBrowser for help on using the repository browser.