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

Last change on this file since 3143 was 3121, checked in by bird, 8 years ago

(C) year)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.3 KB
Line 
1# $Id: qt5.kmk 3121 2017-10-31 10:58:59Z 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) $(dep) '\'
458 $(QUIET2)$(APPEND) $(dep) '$(out): \'
459 $(QUIET2)$(APPEND) $(dep) '$(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
535 %$$(QUIET2)$$(APPEND) '$(dep)'
536 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_'
537 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
538 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
539endif
540
541$(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
542$(target)-inst-nls_SOURCES += $(out)
543
544endef # def_unit_qt5_target_pre_handle_translation_dx
545
546##
547# Handle a source file listed in QT_TRANSLATIONS.
548#
549# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
550# to be translated into .qm files that are loadble by Qt.
551#
552# @remarks Invoked via $(evalvalctx ).
553define def_unit_qt5_target_pre_handle_translation
554local type := LRC
555
556# fetch the properties.
557local tool := $(kb-src-tool dummy_var)
558local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
559local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
560local out := $(outbase).qm
561local dep := $(out).dep
562local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
563local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
564local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
565
566# default path + source dep.
567ifneq ($(defpath),)
568local source := $(abspathex $(source),$(defpath))
569local deps := $(abspathex $(deps),$(defpath)) $(source)
570local incs := $(abspathex $(incs),$(defpath))
571else
572local deps += $(source)
573endif
574
575# call the tool
576ifndef TOOL_$(tool)_LRC_TS_CMDS
577 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
578endif
579local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
580local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
581local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
582local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
583local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
584
585# generate the link rule and update some source and target variables.
586ifndef NO_COMPILE_CMDS_DEPS
587 $(eval includedep $(dep))
588endif
589$(eval $(def_unit_qt5_target_pre_handle_translation_dx))
590
591endef # def_unit_qt5_target_pre_handle_translation
592
593
594
595## wrapper for the UIC command dependencies.
596ifndef NO_COMPILE_CMDS_DEPS
597 _UNIT_QT5_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
598else
599 _UNIT_QT5_RCC_CMDS_DEP =
600endif
601
602##
603# def_unit_qt5_target_pre_handle_qrc helper that is expanded before evaluation.
604#
605# This is necessary to resolve reference to local variables before doing
606# assignments and setting up commands. They would otherwise be resolved
607# later in a different context and the result would be completely wrong.
608#
609define def_unit_qt5_target_pre_handle_rcc_dx
610
611$(out) +| $(realout) $(more_output) $(maybe_output): \
612 $(deps) \
613 $(value _UNIT_QT5_RCC_CMDS_DEP) \
614 | \
615 $(orderdeps)
616 %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
617 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
618
619$(cmds)
620
621 $(QUIET)$(CP) --changed -f $(out) $(realout)
622ifndef NO_COMPILE_CMDS_DEPS
623 %$$(QUIET2)$$(APPEND) '$(dep)'
624 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_'
625 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
626 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
627endif
628
629$(target)_INTERMEDIATES += $(realout)
630$(target)_GEN_SOURCES_ += $(realout)
631$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
632
633endef # def_unit_qt5_target_pre_handle_rcc_dx
634
635##
636# Source handler for .qrc sources (Qt resource files).
637#
638# @remarks $(evalvalctx me).
639define def_unit_qt5_src_handler_qrc
640local type := RCC
641
642# fetch the properties.
643local tool := $(kb-src-tool dummy_var)
644local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
645local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
646local out := $(outbase).tmp.gen.cpp
647local realout := $(outbase).gen.cpp
648local dep := $(realout).dep
649local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
650local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
651local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
652
653# default path + source dep.
654ifneq ($(defpath),)
655local source := $(abspathex $(source),$(defpath))
656local deps := $(abspathex $(deps),$(defpath)) $(source)
657local incs := $(abspathex $(incs),$(defpath))
658else
659local deps += $(source)
660endif
661
662# call the tool
663ifndef TOOL_$(tool)_RCC_QRC_CMDS
664 $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
665endif
666local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
667local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
668local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
669local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
670local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
671
672# generate the link rule and update some source and target variables.
673ifndef NO_COMPILE_CMDS_DEPS
674 $(eval includedep $(dep))
675endif
676$(eval $(def_unit_qt5_target_pre_handle_rcc_dx))
677
678endef # def_unit_qt5_src_handler_qrc
679
680
681
682## wrapper for the UIC command dependencies.
683ifndef NO_COMPILE_CMDS_DEPS
684 _UNIT_QT5_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
685else
686 _UNIT_QT5_UIC_CMDS_DEP =
687endif
688
689##
690# def_unit_qt5_src_handler_ui helper that is expanded before evaluation.
691#
692# This is necessary to resolve reference to local variables before doing
693# assignments and setting up commands. They would otherwise be resolved
694# later in a different context and the result would be completely wrong.
695#
696define def_unit_qt5_target_pre_handle_ui_dx
697
698$(out) +| $(realout) $(more_output) $(maybe_output): \
699 $(deps) \
700 $(value _UNIT_QT5_UIC_CMDS_DEP) \
701 | \
702 $(orderdeps)
703 %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
704 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
705
706$(cmds)
707
708 $(QUIET)$(CP) --changed -f $(out) $(realout)
709ifndef NO_COMPILE_CMDS_DEPS
710 %$$(QUIET2)$$(APPEND) '$(dep)'
711 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_'
712 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
713 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
714endif
715
716$(target)_INTERMEDIATES += $(realout)
717$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
718
719endef # def_unit_qt5_target_pre_handle_ui_dx
720
721##
722# Source handler for .ui sources.
723#
724# @remarks $(evalvalctx me).
725define def_unit_qt5_src_handler_ui
726local type := UIC
727
728# fetch the properties.
729local tool := $(kb-src-tool dummy_var)
730local qtuicdir := $($(target)_0_OUTDIR)/qtuic
731local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
732local out := $(outbase).tmp.gen.h
733local realout := $(outbase).gen.h
734local dep := $(realout).dep
735local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
736local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
737local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
738
739# default path + source dep.
740ifneq ($(defpath),)
741local source := $(abspathex $(source),$(defpath))
742local deps := $(abspathex $(deps),$(defpath)) $(source)
743local incs := $(abspathex $(incs),$(defpath))
744else
745local deps += $(source)
746endif
747
748# call the tool
749ifndef TOOL_$(tool)_UIC_UI_CMDS
750 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
751endif
752local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
753local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
754local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
755local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
756local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
757
758# generate the link rule and update some source and target variables.
759ifndef NO_COMPILE_CMDS_DEPS
760 $(eval includedep $(dep))
761endif
762$(eval $(def_unit_qt5_target_pre_handle_ui_dx))
763
764endef # def_unit_qt5_src_handler_ui
765
766
767
768## wrapper for the MOC command dependencies.
769ifndef NO_COMPILE_CMDS_DEPS
770 _UNIT_QT5_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
771else
772 _UNIT_QT5_MOC_HPP_CMDS_DEP =
773endif
774
775##
776# def_unit_qt5_target_pre_handle_moc_hdr helper that is expanded before evaluation.
777#
778# This is necessary to resolve reference to local variables before doing
779# assignments and setting up commands. They would otherwise be resolved
780# later in a different context and the result would be completely wrong.
781#
782define def_unit_qt5_target_pre_handle_moc_hdr_dx
783
784$(out) +| $(realout) $(more_output) $(maybe_output): \
785 $(deps) \
786 $(value _UNIT_QT5_MOC_HPP_CMDS_DEP) \
787 | \
788 $(orderdeps)
789 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
790 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
791
792$(cmds)
793
794 $(QUIET)$(CP) --changed -f $(out) $(realout)
795ifndef NO_COMPILE_CMDS_DEPS
796 %$$(QUIET2)$$(APPEND) '$(dep)'
797 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_'
798 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
799 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
800endif
801
802$(target)_INTERMEDIATES += $(realout)
803$(target)_GEN_SOURCES_ += $(realout)
804$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
805
806endef
807
808##
809# Handle a source file listed in QT_MOCHDRS.
810#
811# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
812# generate a .cpp file for each of them and add it to the generated
813# sources so that it's compiled and linked. (There is an alternative
814# way to do this where the .cpp file is included, this isn't currently
815# supported by this unit.)
816#
817# @remarks Invoked via $(evalvalctx ).
818define def_unit_qt5_target_pre_handle_moc_hdr
819local type := MOC
820
821# fetch the properties.
822local tool := $(kb-src-tool dummy_var)
823local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
824local out := $(outbase).tmp.cpp
825local realout := $(outbase).cpp
826local dep := $(realout).dep
827local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
828local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
829local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
830local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
831local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
832
833# default path + source dep.
834ifneq ($(defpath),)
835local source := $(abspathex $(source),$(defpath))
836local deps := $(abspathex $(deps),$(defpath)) $(source)
837local incs := $(abspathex $(incs),$(defpath))
838else
839local deps += $(source)
840endif
841
842# call the tool
843ifndef TOOL_$(tool)_MOC_HPP_CMDS
844 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
845endif
846local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
847local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
848local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
849local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
850local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
851
852# generate the link rule and update some source and target variables.
853ifndef NO_COMPILE_CMDS_DEPS
854 $(eval includedep $(dep))
855endif
856$(eval $(def_unit_qt5_target_pre_handle_moc_hdr_dx))
857
858endef # def_unit_qt5_target_pre_handle_moc_hdr
859
860
861## wrapper for the MOC command dependencies.
862ifndef NO_COMPILE_CMDS_DEPS
863 _UNIT_QT5_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
864else
865 _UNIT_QT5_MOC_CPP_CMDS_DEP =
866endif
867
868##
869# def_unit_qt5_target_pre_handle_moc_src helper that is expanded before evaluation.
870#
871# This is necessary to resolve reference to local variables before doing
872# assignments and setting up commands. They would otherwise be resolved
873# later in a different context and the result would be completely wrong.
874#
875define def_unit_qt5_target_pre_handle_moc_src_dx
876
877$(out) +| $(realout) $(more_output) $(maybe_output): \
878 $(deps) \
879 $(value _UNIT_QT5_MOC_CPP_CMDS_DEP) \
880 | \
881 $(orderdeps)
882 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
883 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
884
885$(cmds)
886
887 $(QUIET)$(CP) --changed -f $(out) $(realout)
888ifndef NO_COMPILE_CMDS_DEPS
889 %$$(QUIET2)$$(APPEND) '$(dep)'
890 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_'
891 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
892 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
893endif
894
895$(target)_INTERMEDIATES += $(realout)
896$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
897
898endef
899
900##
901# Handle a source file listed in QT_MOCSRCS.
902#
903# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
904# a .moc file that we're expected to generate here.
905#
906# @remarks Invoked via $(evalvalctx ).
907define def_unit_qt5_target_pre_handle_moc_src
908local type := MOC
909
910# fetch the properties.
911local tool := $(kb-src-tool dummy_var)
912local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
913local out := $(outbase).tmp.moc
914local realout := $(outbase).moc
915local dep := $(realout).dep
916local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
917local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
918local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
919local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
920local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
921
922# default path + source dep.
923ifneq ($(defpath),)
924local source := $(abspathex $(source),$(defpath))
925local deps := $(abspathex $(deps),$(defpath)) $(source)
926local incs := $(abspathex $(incs),$(defpath))
927else
928local deps += $(source)
929endif
930
931# call the tool
932ifndef TOOL_$(tool)_MOC_CPP_CMDS
933 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
934endif
935local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
936local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
937local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
938local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
939local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
940
941# generate the link rule and update some source and target variables.
942ifndef NO_COMPILE_CMDS_DEPS
943 $(eval includedep $(dep))
944endif
945$(eval $(def_unit_qt5_target_pre_handle_moc_src_dx))
946
947endef # def_unit_qt5_target_pre_handle_moc_src
948
949
950##
951# Adds sources containing Q_OBJECT to QT_MOCSRCS.
952define def_unit_qt5_target_pre_cpp_source
953ifneq ($(file-size $(source)),-1)
954 ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
955 $(eval $(target)_QT_MOCSRCS += $(source))
956 endif
957endif
958endef # def_unit_qt5_target_pre_cpp_source
959
960##
961# Invoked early in the processing of a target that uses the Qt unit.
962#
963# It will append the qt source handlers to the target (.h, .ui, .ts,
964# .png, .bmp, .gif).
965#
966# It will then check all the C++ sources and check which needs
967# a .moc files and generate rules and dependencies fofor these
968#
969define def_unit_qt5_target_pre
970
971# Make QTTOOL the default for the specific Qt tools instead of TOOL.
972ifneq ($($(target)_QTTOOL),)
973 ifeq ($($(target)_MOCTOOL),)
974 $(target)_MOCTOOL := $($(target)_QTTOOL)
975 endif
976 ifeq ($($(target)_UICTOOL),)
977 $(target)_UICTOOL := $($(target)_QTTOOL)
978 endif
979 ifeq ($($(target)_RCCTOOL),)
980 $(target)_RCCTOOL := $($(target)_QTTOOL)
981 endif
982 ifeq ($($(target)_LRCTOOL),)
983 $(target)_LRCTOOL := $($(target)_QTTOOL)
984 endif
985endif
986
987# Deal with QT_MODULES, QT_PREFIX and QT_INFIX.
988local qt_modules := \
989 $($(target)_QT_MODULES.$(bld_trg)) \
990 $($(target)_QT_MODULES.$(bld_trg_arch)) \
991 $($(target)_QT_MODULES.$(bld_trg).$(bld_trg_arch)) \
992 $($(target)_QT_MODULES.$(bld_trg_cpu)) \
993 $($(target)_QT_MODULES.$(bld_type)) \
994 $($(target)_QT_MODULES)
995local qt_prefix := $(firstword \
996 $($(target)_QT_PREFIX.$(bld_trg)) \
997 $($(target)_QT_PREFIX.$(bld_trg_arch)) \
998 $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
999 $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
1000 $($(target)_QT_PREFIX.$(bld_type)) \
1001 $($(target)_QT_PREFIX))
1002local qt_infix := $(firstword \
1003 $($(target)_QT_INFIX.$(bld_trg)) \
1004 $($(target)_QT_INFIX.$(bld_trg_arch)) \
1005 $($(target)_QT_INFIX.$(bld_trg).$(bld_trg_arch)) \
1006 $($(target)_QT_INFIX.$(bld_trg_cpu)) \
1007 $($(target)_QT_INFIX.$(bld_type)) \
1008 $($(target)_QT_INFIX))
1009ifeq ($(bld_trg),darwin)
1010 # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
1011 $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT5_LIB) )
1012 $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT5_LIB) )
1013 $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT5_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) )
1014 $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/5/Headers) )
1015else
1016 ifeq ($(bld_trg),win)
1017 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_LIB)) )
1018 ifeq ($(tool_do),LINK_PROGRAM)
1019 $(eval $(target)_LIBS += $(PATH_SDK_QT5_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) )
1020 endif
1021 else
1022 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/lib$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_DLL)) )
1023 endif
1024 $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT5_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT5_INC) )
1025endif
1026$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
1027
1028
1029# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
1030# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
1031ifndef $(target)_QT_MOCSRCS
1032 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
1033 $($(target)_SOURCES.$(bld_trg)) \
1034 $($(target)_SOURCES.$(bld_trg_arch)) \
1035 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1036 $($(target)_SOURCES.$(bld_trg_cpu)) \
1037 $($(target)_SOURCES.$(bld_type)) \
1038 $($(target)_SOURCES) \
1039 ), $(evalval def_unit_qt5_target_pre_cpp_source))
1040endif
1041
1042# Install source handlers for .ui files.
1043$(target)_SRC_HANDLERS += \
1044 .ui:def_unit_qt5_src_handler_ui \
1045 .UI:def_unit_qt5_src_handler_ui \
1046 .qrc:def_unit_qt5_src_handler_qrc \
1047 .qrc:def_unit_qt5_src_handler_qrc
1048
1049# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
1050local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
1051local qtuicdir := $($(target)_0_OUTDIR)/qtuic
1052local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
1053local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
1054$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
1055$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
1056
1057# Deal with QT_MOCSRCS.
1058$(foreach source, \
1059 $($(target)_QT_MOCSRCS.$(bld_trg)) \
1060 $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
1061 $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
1062 $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
1063 $($(target)_QT_MOCSRCS.$(bld_type)) \
1064 $($(target)_QT_MOCSRCS) \
1065 , $(evalvalctx def_unit_qt5_target_pre_handle_moc_src))
1066
1067# Deal with QT_MOCHDRS.
1068$(foreach source, \
1069 $($(target)_QT_MOCHDRS.$(bld_trg)) \
1070 $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
1071 $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
1072 $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
1073 $($(target)_QT_MOCHDRS.$(bld_type)) \
1074 $($(target)_QT_MOCHDRS) \
1075 , $(evalvalctx def_unit_qt5_target_pre_handle_moc_hdr))
1076
1077# Deal with QT_TRANSLATIONS.
1078# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
1079local translations := \
1080 $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
1081 $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
1082 $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
1083 $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
1084 $($(target)_QT_TRANSLATIONS.$(bld_type)) \
1085 $($(target)_QT_TRANSLATIONS)
1086ifneq ($(strip $(translations)),)
1087 local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
1088 $(eval $(expr))
1089 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
1090 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
1091 else
1092 $(target)-inst-nls_MODE := 0644
1093 endif
1094 ifdef $(target)_QT_TRANSLATIONS_INST
1095 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
1096 endif
1097 $(target)-inst-nls_SOURCES :=
1098 $(foreach source, $(translations)\
1099 , $(evalvalctx def_unit_qt5_target_pre_handle_translation))
1100endif
1101
1102endef # def_unit_qt5_target_pre
1103
1104
1105#
1106# Rule for debugging.
1107#
1108unit-qt5-show-vars:
1109 @$(ECHO) 'The Qt5 SDK variables:'
1110 @$(ECHO) ' PATH_SDK_QT5 = "$(PATH_SDK_QT5)"'
1111 @$(ECHO) ' PATH_SDK_QT5_INC = "$(PATH_SDK_QT5_INC)"'
1112 @$(ECHO) ' PATH_SDK_QT5_LIB = "$(PATH_SDK_QT5_LIB)"'
1113 @$(ECHO) ' PATH_SDK_QT5_LIB.amd64 = "$(PATH_SDK_QT5_LIB.amd64)"'
1114 @$(ECHO) ' PATH_SDK_QT5_LIB.x86 = "$(PATH_SDK_QT5_LIB.x86)"'
1115 @$(ECHO) 'The Qt5 TOOL variables:'
1116 @$(ECHO) ' PATH_TOOL_QT5_BIN = "$(PATH_TOOL_QT5_BIN)"'
1117 @$(ECHO) ' TOOL_QT5_BIN_SUFF = "$(TOOL_QT5_BIN_SUFF)"'
1118 @$(ECHO) ' TOOL_QT5_MOC = "$(TOOL_QT5_MOC)"'
1119 @$(ECHO) ' TOOL_QT5_UIC = "$(TOOL_QT5_UIC)"'
1120 @$(ECHO) ' TOOL_QT5_RCC = "$(TOOL_QT5_RCC)"'
1121 @$(ECHO) ' TOOL_QT5_LRC = "$(TOOL_QT5_LRC)"'
1122 @$(ECHO) ' TOOL_QT5_LUPDATE = "$(TOOL_QT5_LUPDATE)"'
1123
Note: See TracBrowser for help on using the repository browser.