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

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

qt5.kmk: duh.

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