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

Last change on this file since 2979 was 2979, checked in by bird, 9 years ago

qt4.kmk,qt5.kmk: fix

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