Built win.arm64 against r3658
[kbuild-mirror.git] / kBuild / units / qt4.kmk
blob567813d064c4ae8d7e547f6cbefcf87a3e60b69e
1 # $Id$
2 ## @file
3 # Qt 4 unit.
7 # Copyright (c) 2008-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
9 # This file is part of kBuild.
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.
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.
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
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.
35 ifdef UNIT_qt4
36 $(error kBuild: The qt4 unit was included twice!)
37 endif
38 UNIT_qt4 = qt4
41 if !defined(UNIT_qt3) && !defined(UNIT_qt5)
42 # Add our target properties (same as qt3 & qt5).
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
45 endif
46 PROPS_SINGLE += RCCTOOL QT_INFIX
47 PROPS_ACCUMULATE_R += RCCFLAGS QT_MODULES
50 ## @todo use pkg-config?
53 # The QT4 SDK.
55 # This is implemented here rather than in sdks/QT4.kmk to enforce the global USES.
56 # It also makes things easier to develop, with fewer files I mean.
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.
60 SDK_QT4 = Qt4
62 # SDK Specific Properties
63 # PATH_SDK_QT4 - The general Qt4 root directory.
64 # PATH_SDK_QT4_INC - The include directory.
65 # PATH_SDK_QT4_LIB.amd64 - The lib directory for AMD64.
66 # PATH_SDK_QT4_LIB.x86 - The lib directory for X86.
67 # PATH_SDK_QT4_LIB - The lib directory for KBUILD_TARGET.
68 ifndef PATH_SDK_QT4
69 PATH_SDK_QT4 := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v4*)))
70 ifeq ($(PATH_SDK_QT4),)
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_QT4 := $(patsubst %/Frameworks/QtCore.framework/Versions/4,%,$(firstword $(wildcard /Library/Frameworks/QtCore.framework/Versions/4)))
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_QT4_LIB* stuff if it doesn't work.
81 # Try find the general root of thing by looking for the qt3to4 program, if not found, then look for rcc.
82 PATH_SDK_QT4 := $(patsubst %/bin/qt3to4-qt4,%,$(firstword $(wildcard \
83 /usr/bin/qt3to4-qt4 \
84 /usr/local/bin/qt3to4-qt4 \
85 /usr/qt/4/bin/qt3to4-qt4 \
86 /usr/share/qt4/bin/qt3to4-qt4 \
87 )))
88 ifeq ($(PATH_SDK_QT4),)
89 PATH_SDK_QT4 := $(patsubst %/bin/qt3to4,%,$(firstword $(wildcard \
90 /usr/bin/qt3to4 \
91 /usr/local/bin/qt3to4 \
92 /usr/qt/4/bin/qt3to4 \
93 /usr/share/qt4/bin/qt3to4 \
94 )))
95 endif
96 ifeq ($(PATH_SDK_QT4),)
97 PATH_SDK_QT4 := $(patsubst %/bin/rcc-qt4,%,$(firstword $(wildcard \
98 /usr/bin/rcc-qt4 \
99 /usr/local/bin/rcc-qt4 \
100 /usr/qt/4/bin/rcc-qt4 \
101 /usr/share/qt4/bin/rcc-qt4 \
103 endif
104 ifeq ($(PATH_SDK_QT4),)
105 PATH_SDK_QT4 := $(patsubst %/bin/rcc,%,$(firstword $(wildcard \
106 /usr/lib/*/qt4/bin/rcc \
107 /usr/bin/rcc \
108 /usr/local/bin/rcc \
109 /usr/qt/4/bin/rcc \
110 /usr/share/qt4/bin/rcc \
112 endif
113 ifneq ($(PATH_SDK_QT4),)
114 export PATH_SDK_QT4
116 # Locate the include files.
117 ifeq ($(PATH_SDK_QT4_INC),)
118 PATH_SDK_QT4_INC := $(patsubst %/QtCore/qglobal.h,%,$(firstword $(wildcard \
119 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt4/QtCore/qglobal.h) \
120 $(PATH_SDK_QT4)/include/QtCore/qglobal.h \
121 $(PATH_SDK_QT4)/include/qt4/QtCore/qglobal.h \
122 /usr/include/qt4/QtCore/qtglobal.h \
123 /usr/local/include/qt4/QtCore/qtglobal.h \
125 ifneq ($(PATH_SDK_QT4_INC),)
126 export PATH_SDK_QT4_INC
127 endif
128 endif
130 # Now for the libraries (mostly for helping out finding the KBUILD_TARGET libs).
131 ifeq ($(PATH_SDK_QT4_LIB.x86),)
132 PATH_SDK_QT4_LIB.x86 := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
133 $(PATH_SDK_QT4)/lib32/libQtCore$(SUFF_DLL) \
134 $(PATH_SDK_QT4)/lib32/qt4/libQtCore$(SUFF_DLL) \
135 /usr/lib32/libQtCore$(SUFF_DLL) \
136 /usr/lib32/qt4/libQtCore$(SUFF_DLL) \
137 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
138 /usr/local/lib32/libQtCore$(SUFF_DLL) \
139 /usr/local/lib32/qt4/libQtCore$(SUFF_DLL) \
140 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
141 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
142 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
143 $(PATH_SDK_QT4)/lib/i386-linux-gnu/libQtCore$(SUFF_DLL) \
145 ifneq ($(PATH_SDK_QT4_LIB.x86),)
146 export PATH_SDK_QT4_LIB.x86
147 endif
148 endif
149 ifeq ($(PATH_SDK_QT4_LIB.amd64),)
150 PATH_SDK_QT4_LIB.amd64 := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
151 $(PATH_SDK_QT4)/lib64/libQtCore$(SUFF_DLL) \
152 $(PATH_SDK_QT4)/lib64/qt4/libQtCore$(SUFF_DLL) \
153 $(PATH_SDK_QT4)/lib/amd64/libQtCore$(SUFF_DLL) \
154 /usr/lib64/libQtCore$(SUFF_DLL) \
155 /usr/lib64/qt4/libQtCore$(SUFF_DLL) \
156 /usr/lib/amd64/libQtCore$(SUFF_DLL) \
157 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
158 /usr/local/lib64/libQtCore$(SUFF_DLL) \
159 /usr/local/lib64/qt4/libQtCore$(SUFF_DLL) \
160 /usr/local/lib/amd64/libQtCore$(SUFF_DLL) \
161 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
162 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
163 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
164 $(PATH_SDK_QT4)/lib/x86_64-linux-gnu/libQtCore$(SUFF_DLL) \
166 ifneq ($(PATH_SDK_QT4_LIB.amd64),)
167 export PATH_SDK_QT4_LIB.amd64
168 endif
169 endif
171 # And finally, the library path for KBUILD_TARGET.
172 ifeq ($(PATH_SDK_QT4_LIB),)
173 PATH_SDK_QT4_LIB := $(PATH_SDK_QT4_LIB.$(KBUILD_TARGET_ARCH))
174 ifeq ($(PATH_SDK_QT4_LIB),)
175 PATH_SDK_QT4_LIB := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
176 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
177 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
178 /usr/lib/libQtCore$(SUFF_DLL) \
179 /usr/lib/qt4/libQtCore$(SUFF_DLL) \
180 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
181 /usr/local/lib/libQtCore$(SUFF_DLL) \
182 /usr/local/lib/qt4/libQtCore$(SUFF_DLL) \
183 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
185 endif
186 ifneq ($(PATH_SDK_QT4_LIB),)
187 export PATH_SDK_QT4_LIB
188 endif
189 endif
191 endif
192 endif # Unices
193 endif
194 # Found it?
195 ifeq ($(PATH_SDK_QT4),)
196 $(warning kBuild: Couldn't find the Qt4 headers and libaries...)
197 PATH_SDK_QT4 := $(KBUILD_DEVTOOLS_TRG)/qt/not-found
198 endif
199 endif
200 else
201 # Resolve any fancy stuff once and for all.
202 PATH_SDK_QT4 := $(PATH_SDK_QT4)
203 endif
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.
207 ifeq ($(KBUILD_TARGET),darwin)
208 ifndef PATH_SDK_QT4_LIB
209 ifneq ($(wildcard $(PATH_SDK_QT4)/Frameworks),)
210 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/Frameworks
211 else
212 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/lib
213 endif
214 endif
215 else
216 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/lib
217 PATH_SDK_QT4_INC ?= $(PATH_SDK_QT4)/include
218 endif
220 # The bits that kBuild picks up.
221 # (nothing here)
225 # The QT4 tool.
227 # This is implemented here rather than in tools/QT4.kmk to enforce the global USES.
228 # It also makes things easier to develop, with fewer files I mean.
230 TOOL_QT4 = Qt4
232 # Tool Specific Properties
233 # PATH_TOOL_QT4 - Obsolete.
234 # PATH_TOOL_QT4_BIN - The
235 # TOOL_QT4_BIN_SUFF -
236 if !defined(PATH_TOOL_QT4_BIN) && defined(PATH_TOOL_QT4)
237 PATH_TOOL_QT4_BIN := $(PATH_TOOL_QT4)/bin
238 endif
239 ifndef PATH_TOOL_QT4_BIN
240 PATH_TOOL_QT4_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST)/qt/v4*/bin)))
241 if "$(PATH_TOOL_QT4_BIN)" == "" && "$(KBUILD_DEVTOOLS_HST_ALT)" != ""
242 PATH_TOOL_QT4_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST_ALT)/qt/v4*/bin)))
243 endif
244 ifeq ($(PATH_TOOL_QT4_BIN),)
245 ifdef TOOL_QT4_BIN_SUFF
246 TOOL_QT4_BIN_SUFF := $(TOOL_QT4_BIN_SUFF)
247 endif
248 # Try looking for moc-$(suffix) first, if specified.
249 ifneq ($(TOOL_QT4_BIN_SUFF),)
250 PATH_TOOL_QT4_BIN := $(patsubst %/moc$(TOOL_QT4_BIN_SUFF),%,$(firstword $(wildcard \
251 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/moc$(TOOL_QT4_BIN_SUFF)) \
252 /usr/lib/qt4/bin/moc$(TOOL_QT4_BIN_SUFF) \
253 /usr/qt/4/bin/moc$(TOOL_QT4_BIN_SUFF) \
254 /usr/share/qt4/bin/moc$(TOOL_QT4_BIN_SUFF) \
255 /usr/local/bin/moc$(TOOL_QT4_BIN_SUFF) \
256 /usr/bin/moc$(TOOL_QT4_BIN_SUFF) \
258 else
259 # No suffix given, so before we check out -qt4 look at qt4 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)/qt4/bin/moc) \
262 $(if $(intersects $(KBUILD_HOST_ARCH), $(KBUILD_ARCHES_64)),/usr/lib64/qt4/bin/moc,) \
263 /usr/lib/qt4/bin/moc \
264 /usr/local/lib/qt4/bin/moc \
265 /usr/qt/4/bin/moc \
266 /usr/local/qt/4/bin/moc \
267 /usr/share/qt4/bin/moc \
268 /usr/local/share/qt4/bin/moc \
270 ifeq ($(PATH_TOOL_QT4_BIN),)
271 PATH_TOOL_QT4_BIN := $(patsubst %/moc-qt4,%,$(firstword $(wildcard \
272 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/moc-qt4) \
273 /usr/lib/qt4/bin/moc-qt4 \
274 /usr/qt/4/bin/moc-qt4 \
275 /usr/share/qt4/bin/moc-qt4 \
276 /usr/local/bin/moc-qt4 \
277 /usr/bin/moc-qt4 \
279 ifneq ($(PATH_TOOL_QT4_BIN),)
280 TOOL_QT4_BIN_SUFF := -qt4
281 endif
282 endif
283 endif
284 # If still no go, try looking for qt3to4 and rcc.
285 ifeq ($(PATH_TOOL_QT4_BIN),)
286 PATH_TOOL_QT4_BIN := $(patsubst %/qt3to4,%,$(firstword $(wildcard \
287 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/qt3to4) \
288 /usr/lib/qt4/bin/qt3to4 \
289 /usr/qt/4/bin/qt3to4 \
290 /usr/share/qt4/bin/qt3to4 \
291 /usr/local/bin/qt3to4 \
292 /usr/bin/qt3to4 \
294 endif
295 ifeq ($(PATH_TOOL_QT4_BIN),)
296 PATH_TOOL_QT4_BIN := $(patsubst %/rcc$(TOOL_QT4_BIN_SUFF),%,$(firstword $(wildcard \
297 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF)) \
298 /usr/lib/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
299 /usr/qt/4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
300 /usr/share/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
301 /usr/local/bin/rcc$(TOOL_QT4_BIN_SUFF) \
302 /usr/bin/rcc$(TOOL_QT4_BIN_SUFF) \
304 endif
305 if "$(PATH_TOOL_QT4_BIN)" == "" && "$(TOOL_QT4_BIN_SUFF)" != ""
306 PATH_TOOL_QT4_BIN := $(patsubst %/rcc,%,$(firstword $(wildcard \
307 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/rcc) \
308 /usr/lib/qt4/bin/rcc \
309 /usr/qt/4/bin/rcc \
310 /usr/share/qt4/bin/rcc \
311 /usr/local/bin/rcc \
312 /usr/bin/rcc \
314 endif
315 ifneq ($(PATH_TOOL_QT4_BIN),)
316 export PATH_TOOL_QT4_BIN
317 endif
318 endif
319 # If not found, we'll enter the 'pathless' mode.
320 else
321 # Resolve any fancy stuff once and for all.
322 PATH_TOOL_QT4_BIN := $(PATH_TOOL_QT4_BIN)
323 endif
324 ifneq ($(PATH_TOOL_QT4_BIN),)
325 TOOL_QT4_MOC ?= $(PATH_TOOL_QT4_BIN)/moc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
326 TOOL_QT4_UIC ?= $(PATH_TOOL_QT4_BIN)/uic$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
327 ifndef TOOL_QT4_RCC
328 TOOL_QT4_RCC := $(PATH_TOOL_QT4_BIN)/rcc$(HOST_SUFF_EXE)
329 ifeq ($(wildcard $(TOOL_QT4_RCC)),)
330 TOOL_QT4_RCC := $(PATH_TOOL_QT4_BIN)/rcc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
331 endif
332 endif
333 TOOL_QT4_LRC ?= $(PATH_TOOL_QT4_BIN)/lrelease$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
334 TOOL_QT4_LUPDATE ?= $(PATH_TOOL_QT4_BIN)/lupdate$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
335 else
336 # Pathless, relies on the environment.
337 TOOL_QT4_MOC ?= moc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
338 TOOL_QT4_UIC ?= uic$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
339 TOOL_QT4_RCC ?= rcc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
340 TOOL_QT4_LRC ?= lrelease$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
341 TOOL_QT4_LUPDATE ?= lupdate$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
342 endif
344 # General Properties used by kBuild and/or units/qt.kmk
345 TOOL_QT4_MOCFLAGS ?=
346 TOOL_QT4_MOCINCS ?=
347 TOOL_QT4_MOCDEFS ?=
348 TOOL_QT4_MOCDEFS.darwin ?= __APPLE__ __GNUC__
349 TOOL_QT4_MOCDEFS.solaris ?= __sun
350 TOOL_QT4_MOCDEFS.win.amd64 ?= WIN64
351 TOOL_QT4_MOCDEFS.win.x86 ?= WIN32
354 ## MOC a C++ source file.
355 # @param $(target) Normalized main target name.
356 # @param $(source) Source filename (relative).
357 # @param $(out) Object file name. This shall be (re)created by the compilation.
358 # @param $(dep) Dependcy file. This may be (re)created by the compilation.
359 # @param $(flags) Flags.
360 # @param $(defs) Definitions.
361 # @param $(incs) Includes.
362 # @param $(outbase) Output basename (full). Use this for list files and such.
364 TOOL_QT4_MOC_CPP_DEPEND =
365 TOOL_QT4_MOC_CPP_DEPORD =
366 TOOL_QT4_MOC_CPP_OUTPUT =
367 TOOL_QT4_MOC_CPP_OUTPUT_MAYBE =
368 define TOOL_QT4_MOC_CPP_CMDS
369 $(QUIET)$(TOOL_QT4_MOC)\
370 $(flags)\
371 $(addprefix -I, $(incs))\
372 $(addprefix -D, $(defs))\
373 -o $(out)\
374 $(source)
375 endef
377 ## MOC a C++ header file.
378 # @param $(target) Normalized main target name.
379 # @param $(source) Source filename (relative).
380 # @param $(out) Object file name. This shall be (re)created by the compilation.
381 # @param $(dep) Dependcy file. This may be (re)created by the compilation.
382 # @param $(flags) Flags.
383 # @param $(defs) Definitions.
384 # @param $(incs) Includes.
385 # @param $(outbase) Output basename (full). Use this for list files and such.
387 TOOL_QT4_MOC_HPP_DEPEND =
388 TOOL_QT4_MOC_HPP_DEPORD =
389 TOOL_QT4_MOC_HPP_OUTPUT =
390 TOOL_QT4_MOC_HPP_OUTPUT_MAYBE =
391 define TOOL_QT4_MOC_HPP_CMDS
392 $(QUIET)$(TOOL_QT4_MOC)\
393 $(flags)\
394 $(addprefix -I, $(incs))\
395 $(addprefix -D, $(defs))\
396 -o $(out)\
397 $(source)
398 endef
400 ## Compile a Qt user interface file (.ui).
401 # @param $(target) Normalized main target name.
402 # @param $(source) Source filename (relative).
403 # @param $(out) Object file name. This shall be (re)created by the compilation.
404 # @param $(dep) Dependcy file. This may be (re)created by the compilation.
405 # @param $(flags) Flags.
406 # @param $(defs) Definitions.
407 # @param $(incs) Includes.
408 # @param $(outbase) Output basename (full). Use this for list files and such.
410 TOOL_QT4_UIC_UI_DEPEND =
411 TOOL_QT4_UIC_UI_DEPORD =
412 TOOL_QT4_UIC_UI_OUTPUT =
413 TOOL_QT4_UIC_UI_OUTPUT_MAYBE =
414 define TOOL_QT4_UIC_UI_CMDS
415 $(QUIET)$(TOOL_QT4_UIC)\
416 $(flags)\
417 -o $(out)\
418 $(source)
419 endef
421 ## Compile a Qt resource file (.qrc).
422 # @param $(target) Normalized main target name.
423 # @param $(source) Source filename (relative).
424 # @param $(out) Object file name. This shall be (re)created by the compilation.
425 # @param $(dep) Dependcy file. This may be (re)created by the compilation.
426 # @param $(flags) Flags.
427 # @param $(defs) Definitions.
428 # @param $(incs) Includes.
429 # @param $(outbase) Output basename (full). Use this for list files and such.
431 # @remarks The sed script generating the dependency file is a bit naive.
432 TOOL_QT4_RCC_QRC_DEPEND =
433 TOOL_QT4_RCC_QRC_DEPORD =
434 TOOL_QT4_RCC_QRC_OUTPUT =
435 TOOL_QT4_RCC_QRC_OUTPUT_MAYBE =
436 define TOOL_QT4_RCC_QRC_CMDS
437 $(QUIET)$(TOOL_QT4_RCC)\
438 $(flags)\
439 -o $(out)\
440 $(source)
441 $(QUIET2)$(APPEND) $(dep) '\'
442 $(QUIET2)$(APPEND) $(dep) '$(out): \'
443 $(QUIET2)$(APPEND) $(dep) '$(source) \'
444 $(QUIET2)$(SED) \
445 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
446 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
447 -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
448 -e 's|$$$$| \\|' \
449 --append $(dep) \
450 $(source)
451 $(QUIET2)$(APPEND) $(dep)
452 $(QUIET2)$(SED) \
453 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
454 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
455 -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
456 -e 's|$$$$|:\n|' \
457 --append $(dep) \
458 $(source)
459 $(QUIET2)$(APPEND) $(dep)
460 endef
462 ## Compile a Qt translation file (.ts).
463 # @param $(target) Normalized main target name.
464 # @param $(source) Source filename (relative).
465 # @param $(out) Object file name. This shall be (re)created by the compilation.
466 # @param $(dep) Dependcy file. This may be (re)created by the compilation.
467 # @param $(flags) Flags.
468 # @param $(defs) Definitions.
469 # @param $(incs) Includes.
470 # @param $(outbase) Output basename (full). Use this for list files and such.
472 TOOL_QT4_LRC_TS_DEPEND =
473 TOOL_QT4_LRC_TS_DEPORD =
474 TOOL_QT4_LRC_TS_OUTPUT =
475 TOOL_QT4_LRC_TS_OUTPUT_MAYBE =
476 define TOOL_QT4_LRC_TS_CMDS
477 $(QUIET)$(TOOL_QT4_LRC)\
478 $(flags)\
479 $(source)\
480 -qm $(out)
481 endef
487 # Back to the Qt4 unit.
492 ## wrapper for the lrelease (LRC) command dependencies.
493 ifndef NO_COMPILE_CMDS_DEPS
494 _UNIT_QT4_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
495 else
496 _UNIT_QT4_LRC_CMDS_DEP =
497 endif
500 # def_unit_qt4_target_pre_handle_translation helper that is expanded before evaluation.
502 # This is necessary to resolve reference to local variables before doing
503 # assignments and setting up commands. They would otherwise be resolved
504 # later in a different context and the result would be completely wrong.
506 define def_unit_qt4_target_pre_handle_translation_dx
508 $(out) + $(more_output) +| $(maybe_output): \
509 $(deps) \
510 $(value _UNIT_QT4_LRC_CMDS_DEP) \
512 $(orderdeps)
513 %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
514 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
516 $(cmds)
518 ifndef NO_COMPILE_CMDS_DEPS
519 %$$(QUIET2)$$(APPEND) '$(dep)'
520 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_'
521 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
522 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
523 endif
525 $(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
526 $(target)-inst-nls_SOURCES += $(out)
528 endef # def_unit_qt4_target_pre_handle_translation_dx
531 # Handle a source file listed in QT_TRANSLATIONS.
533 # The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
534 # to be translated into .qm files that are loadble by Qt.
536 # @remarks Invoked via $(evalvalctx ).
537 define def_unit_qt4_target_pre_handle_translation
538 local type := LRC
540 # fetch the properties.
541 local tool := $(kb-src-tool dummy_var)
542 local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
543 local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
544 local out := $(outbase).qm
545 local dep := $(out).dep
546 local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
547 local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
548 local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
550 # default path + source dep.
551 ifneq ($(defpath),)
552 local source := $(abspathex $(source),$(defpath))
553 local deps := $(abspathex $(deps),$(defpath)) $(source)
554 local incs := $(abspathex $(incs),$(defpath))
555 else
556 local deps += $(source)
557 endif
559 # call the tool
560 ifndef TOOL_$(tool)_LRC_TS_CMDS
561 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
562 endif
563 local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
564 local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
565 local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
566 local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
567 local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
569 # generate the link rule and update some source and target variables.
570 ifndef NO_COMPILE_CMDS_DEPS
571 $(eval includedep $(dep))
572 endif
573 $(eval $(def_unit_qt4_target_pre_handle_translation_dx))
575 endef # def_unit_qt4_target_pre_handle_translation
579 ## wrapper for the UIC command dependencies.
580 ifndef NO_COMPILE_CMDS_DEPS
581 _UNIT_QT4_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
582 else
583 _UNIT_QT4_RCC_CMDS_DEP =
584 endif
587 # def_unit_qt4_target_pre_handle_qrc helper that is expanded before evaluation.
589 # This is necessary to resolve reference to local variables before doing
590 # assignments and setting up commands. They would otherwise be resolved
591 # later in a different context and the result would be completely wrong.
593 define def_unit_qt4_target_pre_handle_rcc_dx
595 $(out) +| $(realout) $(more_output) $(maybe_output): \
596 $(deps) \
597 $(value _UNIT_QT4_RCC_CMDS_DEP) \
599 $(orderdeps)
600 %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
601 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
603 $(cmds)
605 $(QUIET)$(CP) --changed -f $(out) $(realout)
606 ifndef NO_COMPILE_CMDS_DEPS
607 %$$(QUIET2)$$(APPEND) '$(dep)'
608 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_'
609 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
610 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
611 endif
613 $(target)_2_INTERMEDIATES += $(realout)
614 $(target)_GEN_SOURCES_ += $(realout)
615 $(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
617 endef # def_unit_qt4_target_pre_handle_rcc_dx
620 # Source handler for .qrc sources (Qt resource files).
622 # @remarks $(evalvalctx me).
623 define def_unit_qt4_src_handler_qrc
624 local type := RCC
626 # fetch the properties.
627 local tool := $(kb-src-tool dummy_var)
628 local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
629 local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
630 local out := $(outbase).tmp.gen.cpp
631 local realout := $(outbase).gen.cpp
632 local dep := $(realout).dep
633 local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
634 local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
635 local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
637 # default path + source dep.
638 ifneq ($(defpath),)
639 local source := $(abspathex $(source),$(defpath))
640 local deps := $(abspathex $(deps),$(defpath)) $(source)
641 local incs := $(abspathex $(incs),$(defpath))
642 else
643 local deps += $(source)
644 endif
646 # call the tool
647 ifndef TOOL_$(tool)_RCC_QRC_CMDS
648 $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
649 endif
650 local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
651 local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
652 local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
653 local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
654 local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
656 # generate the link rule and update some source and target variables.
657 ifndef NO_COMPILE_CMDS_DEPS
658 $(eval includedep $(dep))
659 endif
660 $(eval $(def_unit_qt4_target_pre_handle_rcc_dx))
662 endef # def_unit_qt4_src_handler_qrc
666 ## wrapper for the UIC command dependencies.
667 ifndef NO_COMPILE_CMDS_DEPS
668 _UNIT_QT4_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
669 else
670 _UNIT_QT4_UIC_CMDS_DEP =
671 endif
674 # def_unit_qt4_src_handler_ui helper that is expanded before evaluation.
676 # This is necessary to resolve reference to local variables before doing
677 # assignments and setting up commands. They would otherwise be resolved
678 # later in a different context and the result would be completely wrong.
680 define def_unit_qt4_target_pre_handle_ui_dx
682 $(out) +| $(realout) $(more_output) $(maybe_output): \
683 $(deps) \
684 $(value _UNIT_QT4_UIC_CMDS_DEP) \
686 $(orderdeps)
687 %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
688 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
690 $(cmds)
692 $(QUIET)$(CP) --changed -f $(out) $(realout)
693 ifndef NO_COMPILE_CMDS_DEPS
694 %$$(QUIET2)$$(APPEND) '$(dep)'
695 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_'
696 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
697 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
698 endif
700 $(target)_2_INTERMEDIATES += $(realout)
701 $(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
703 endef # def_unit_qt4_target_pre_handle_ui_dx
706 # Source handler for .ui sources.
708 # @remarks $(evalvalctx me).
709 define def_unit_qt4_src_handler_ui
710 local type := UIC
712 # fetch the properties.
713 local tool := $(kb-src-tool dummy_var)
714 local qtuicdir := $($(target)_0_OUTDIR)/qtuic
715 local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
716 local out := $(outbase).tmp.gen.h
717 local realout := $(outbase).gen.h
718 local dep := $(realout).dep
719 local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
720 local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
721 local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
723 # default path + source dep.
724 ifneq ($(defpath),)
725 local source := $(abspathex $(source),$(defpath))
726 local deps := $(abspathex $(deps),$(defpath)) $(source)
727 local incs := $(abspathex $(incs),$(defpath))
728 else
729 local deps += $(source)
730 endif
732 # call the tool
733 ifndef TOOL_$(tool)_UIC_UI_CMDS
734 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
735 endif
736 local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
737 local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
738 local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
739 local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
740 local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
742 # generate the link rule and update some source and target variables.
743 ifndef NO_COMPILE_CMDS_DEPS
744 $(eval includedep $(dep))
745 endif
746 $(eval $(def_unit_qt4_target_pre_handle_ui_dx))
748 endef # def_unit_qt4_src_handler_ui
752 ## wrapper for the MOC command dependencies.
753 ifndef NO_COMPILE_CMDS_DEPS
754 _UNIT_QT4_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
755 else
756 _UNIT_QT4_MOC_HPP_CMDS_DEP =
757 endif
760 # def_unit_qt4_target_pre_handle_moc_hdr helper that is expanded before evaluation.
762 # This is necessary to resolve reference to local variables before doing
763 # assignments and setting up commands. They would otherwise be resolved
764 # later in a different context and the result would be completely wrong.
766 define def_unit_qt4_target_pre_handle_moc_hdr_dx
768 $(out) +| $(realout) $(more_output) $(maybe_output): \
769 $(deps) \
770 $(value _UNIT_QT4_MOC_HPP_CMDS_DEP) \
772 $(orderdeps)
773 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
774 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
776 $(cmds)
778 $(QUIET)$(CP) --changed -f $(out) $(realout)
779 ifndef NO_COMPILE_CMDS_DEPS
780 %$$(QUIET2)$$(APPEND) '$(dep)'
781 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_'
782 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
783 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
784 endif
786 $(target)_2_INTERMEDIATES += $(realout)
787 $(target)_GEN_SOURCES_ += $(realout)
788 $(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
790 endef
793 # Handle a source file listed in QT_MOCHDRS.
795 # The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
796 # generate a .cpp file for each of them and add it to the generated
797 # sources so that it's compiled and linked. (There is an alternative
798 # way to do this where the .cpp file is included, this isn't currently
799 # supported by this unit.)
801 # @remarks Invoked via $(evalvalctx ).
802 define def_unit_qt4_target_pre_handle_moc_hdr
803 local type := MOC
805 # fetch the properties.
806 local tool := $(kb-src-tool dummy_var)
807 local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
808 local out := $(outbase).tmp.cpp
809 local realout := $(outbase).cpp
810 local dep := $(realout).dep
811 local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
812 local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
813 local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
814 local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
815 local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
817 # default path + source dep.
818 ifneq ($(defpath),)
819 local source := $(abspathex $(source),$(defpath))
820 local deps := $(abspathex $(deps),$(defpath)) $(source)
821 local incs := $(abspathex $(incs),$(defpath))
822 else
823 local deps += $(source)
824 endif
826 # call the tool
827 ifndef TOOL_$(tool)_MOC_HPP_CMDS
828 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
829 endif
830 local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
831 local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
832 local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
833 local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
834 local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
836 # generate the link rule and update some source and target variables.
837 ifndef NO_COMPILE_CMDS_DEPS
838 $(eval includedep $(dep))
839 endif
840 $(eval $(def_unit_qt4_target_pre_handle_moc_hdr_dx))
842 endef # def_unit_qt4_target_pre_handle_moc_hdr
845 ## wrapper for the MOC command dependencies.
846 ifndef NO_COMPILE_CMDS_DEPS
847 _UNIT_QT4_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
848 else
849 _UNIT_QT4_MOC_CPP_CMDS_DEP =
850 endif
853 # def_unit_qt4_target_pre_handle_moc_src helper that is expanded before evaluation.
855 # This is necessary to resolve reference to local variables before doing
856 # assignments and setting up commands. They would otherwise be resolved
857 # later in a different context and the result would be completely wrong.
859 define def_unit_qt4_target_pre_handle_moc_src_dx
861 $(out) +| $(realout) $(more_output) $(maybe_output): \
862 $(deps) \
863 $(value _UNIT_QT4_MOC_CPP_CMDS_DEP) \
865 $(orderdeps)
866 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
867 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
869 $(cmds)
871 $(QUIET)$(CP) --changed -f $(out) $(realout)
872 ifndef NO_COMPILE_CMDS_DEPS
873 %$$(QUIET2)$$(APPEND) '$(dep)'
874 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_'
875 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
876 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
877 endif
879 $(target)_2_INTERMEDIATES += $(realout)
880 $(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
882 endef
885 # Handle a source file listed in QT_MOCSRCS.
887 # The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
888 # a .moc file that we're expected to generate here.
890 # @remarks Invoked via $(evalvalctx ).
891 define def_unit_qt4_target_pre_handle_moc_src
892 local type := MOC
894 # fetch the properties.
895 local tool := $(kb-src-tool dummy_var)
896 local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
897 local out := $(outbase).tmp.moc
898 local realout := $(outbase).moc
899 local dep := $(realout).dep
900 local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
901 local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
902 local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
903 local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
904 local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
906 # default path + source dep.
907 ifneq ($(defpath),)
908 local source := $(abspathex $(source),$(defpath))
909 local deps := $(abspathex $(deps),$(defpath)) $(source)
910 local incs := $(abspathex $(incs),$(defpath))
911 else
912 local deps += $(source)
913 endif
915 # call the tool
916 ifndef TOOL_$(tool)_MOC_CPP_CMDS
917 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
918 endif
919 local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
920 local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
921 local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
922 local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
923 local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
925 # generate the link rule and update some source and target variables.
926 ifndef NO_COMPILE_CMDS_DEPS
927 $(eval includedep $(dep))
928 endif
929 $(eval $(def_unit_qt4_target_pre_handle_moc_src_dx))
931 endef # def_unit_qt4_target_pre_handle_moc_src
935 # Adds sources containing Q_OBJECT to QT_MOCSRCS.
936 define def_unit_qt4_target_pre_cpp_source
937 ifneq ($(file-size $(source)),-1)
938 ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
939 $(eval $(target)_QT_MOCSRCS += $(source))
940 endif
941 endif
942 endef # def_unit_qt4_target_pre_cpp_source
945 # Invoked early in the processing of a target that uses the Qt unit.
947 # It will append the qt source handlers to the target (.h, .ui, .ts,
948 # .png, .bmp, .gif).
950 # It will then check all the C++ sources and check which needs
951 # a .moc files and generate rules and dependencies fofor these
953 define def_unit_qt4_target_pre
955 # Make QTTOOL the default for the specific Qt tools instead of TOOL.
956 ifneq ($($(target)_QTTOOL),)
957 ifeq ($($(target)_MOCTOOL),)
958 $(target)_MOCTOOL := $($(target)_QTTOOL)
959 endif
960 ifeq ($($(target)_UICTOOL),)
961 $(target)_UICTOOL := $($(target)_QTTOOL)
962 endif
963 ifeq ($($(target)_RCCTOOL),)
964 $(target)_RCCTOOL := $($(target)_QTTOOL)
965 endif
966 ifeq ($($(target)_LRCTOOL),)
967 $(target)_LRCTOOL := $($(target)_QTTOOL)
968 endif
969 endif
971 # Deal with QT_MODULES, QT_PREFIX and QT_INFIX.
972 local qt_modules := \
973 $($(target)_QT_MODULES.$(bld_trg)) \
974 $($(target)_QT_MODULES.$(bld_trg_arch)) \
975 $($(target)_QT_MODULES.$(bld_trg).$(bld_trg_arch)) \
976 $($(target)_QT_MODULES.$(bld_trg_cpu)) \
977 $($(target)_QT_MODULES.$(bld_type)) \
978 $($(target)_QT_MODULES)
979 local qt_prefix := $(firstword \
980 $($(target)_QT_PREFIX.$(bld_trg)) \
981 $($(target)_QT_PREFIX.$(bld_trg_arch)) \
982 $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
983 $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
984 $($(target)_QT_PREFIX.$(bld_type)) \
985 $($(target)_QT_PREFIX))
986 local qt_infix := $(firstword \
987 $($(target)_QT_INFIX.$(bld_trg)) \
988 $($(target)_QT_INFIX.$(bld_trg_arch)) \
989 $($(target)_QT_INFIX.$(bld_trg).$(bld_trg_arch)) \
990 $($(target)_QT_INFIX.$(bld_trg_cpu)) \
991 $($(target)_QT_INFIX.$(bld_type)) \
992 $($(target)_QT_INFIX))
993 ifeq ($(bld_trg),darwin)
994 # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
995 $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT4_LIB) )
996 $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT4_LIB) )
997 $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT4_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) )
998 $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/4/Headers) )
999 else
1000 ifeq ($(bld_trg),win)
1001 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)$(qt_infix)4$(SUFF_LIB)) )
1002 ifeq ($(tool_do),LINK_PROGRAM)
1003 $(eval $(target)_LIBS += $(PATH_SDK_QT4_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) )
1004 endif
1005 else
1006 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/lib$(qt_prefix)Qt$(module)$(qt_infix)$(SUFF_DLL)) )
1007 endif
1008 $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT4_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT4_INC) )
1009 endif
1010 $(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
1013 # Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
1014 # Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
1015 ifndef $(target)_QT_MOCSRCS
1016 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
1017 $($(target)_SOURCES.$(bld_trg)) \
1018 $($(target)_SOURCES.$(bld_trg_arch)) \
1019 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1020 $($(target)_SOURCES.$(bld_trg_cpu)) \
1021 $($(target)_SOURCES.$(bld_type)) \
1022 $($(target)_SOURCES) \
1023 ), $(evalval def_unit_qt4_target_pre_cpp_source))
1024 endif
1026 # Install source handlers for .ui files.
1027 $(target)_SRC_HANDLERS += \
1028 .ui:def_unit_qt4_src_handler_ui \
1029 .UI:def_unit_qt4_src_handler_ui \
1030 .qrc:def_unit_qt4_src_handler_qrc \
1031 .qrc:def_unit_qt4_src_handler_qrc
1033 # Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
1034 local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
1035 local qtuicdir := $($(target)_0_OUTDIR)/qtuic
1036 local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
1037 local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
1038 $(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
1039 $(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
1041 # Deal with QT_MOCSRCS.
1042 $(foreach source, \
1043 $($(target)_QT_MOCSRCS.$(bld_trg)) \
1044 $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
1045 $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
1046 $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
1047 $($(target)_QT_MOCSRCS.$(bld_type)) \
1048 $($(target)_QT_MOCSRCS) \
1049 , $(evalvalctx def_unit_qt4_target_pre_handle_moc_src))
1051 # Deal with QT_MOCHDRS.
1052 $(foreach source, \
1053 $($(target)_QT_MOCHDRS.$(bld_trg)) \
1054 $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
1055 $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
1056 $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
1057 $($(target)_QT_MOCHDRS.$(bld_type)) \
1058 $($(target)_QT_MOCHDRS) \
1059 , $(evalvalctx def_unit_qt4_target_pre_handle_moc_hdr))
1061 # Deal with QT_TRANSLATIONS.
1062 # ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
1063 local translations := \
1064 $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
1065 $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
1066 $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
1067 $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
1068 $($(target)_QT_TRANSLATIONS.$(bld_type)) \
1069 $($(target)_QT_TRANSLATIONS)
1070 ifneq ($(strip $(translations)),)
1071 local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
1072 $(eval $(expr))
1073 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
1074 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
1075 else
1076 $(target)-inst-nls_MODE := 0644
1077 endif
1078 ifdef $(target)_QT_TRANSLATIONS_INST
1079 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
1080 endif
1081 $(target)-inst-nls_SOURCES :=
1082 $(foreach source, $(translations)\
1083 , $(evalvalctx def_unit_qt4_target_pre_handle_translation))
1084 endif
1086 endef # def_unit_qt4_target_pre
1090 # Rule for debugging.
1092 unit-qt4-show-vars:
1093 @$(ECHO) 'The Qt4 SDK variables:'
1094 @$(ECHO) ' PATH_SDK_QT4 = "$(PATH_SDK_QT4)"'
1095 @$(ECHO) ' PATH_SDK_QT4_INC = "$(PATH_SDK_QT4_INC)"'
1096 @$(ECHO) ' PATH_SDK_QT4_LIB = "$(PATH_SDK_QT4_LIB)"'
1097 @$(ECHO) ' PATH_SDK_QT4_LIB.amd64 = "$(PATH_SDK_QT4_LIB.amd64)"'
1098 @$(ECHO) ' PATH_SDK_QT4_LIB.x86 = "$(PATH_SDK_QT4_LIB.x86)"'
1099 @$(ECHO) 'The Qt4 TOOL variables:'
1100 @$(ECHO) ' PATH_TOOL_QT4_BIN = "$(PATH_TOOL_QT4_BIN)"'
1101 @$(ECHO) ' TOOL_QT4_BIN_SUFF = "$(TOOL_QT4_BIN_SUFF)"'
1102 @$(ECHO) ' TOOL_QT4_MOC = "$(TOOL_QT4_MOC)"'
1103 @$(ECHO) ' TOOL_QT4_UIC = "$(TOOL_QT4_UIC)"'
1104 @$(ECHO) ' TOOL_QT4_RCC = "$(TOOL_QT4_RCC)"'
1105 @$(ECHO) ' TOOL_QT4_LRC = "$(TOOL_QT4_LRC)"'
1106 @$(ECHO) ' TOOL_QT4_LUPDATE = "$(TOOL_QT4_LUPDATE)"'