source: trunk/kBuild/units/qt4.kmk@ 1736

Last change on this file since 1736 was 1689, checked in by bird, 17 years ago

qt4: fixed .qrc dependency generation, attached the dependency list to the wrong file.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 30.4 KB
Line 
1# $Id: qt4.kmk 1689 2008-08-26 18:42:40Z bird $
2## @file
3# Qt 4 unit.
4#
5
6#
7# Copyright (c) 2008 knut st. osmundsen <bird-src-spam@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
27ifdef UNIT_qt4
28 $(error kBuild: The qt4 unit was included twice!)
29endif
30UNIT_qt4 = qt4
31
32
33ifndef UNIT_qt3
34 # Add our target properties (same as qt3).
35 PROPS_SINGLE += QTTOOL MOCTOOL UICTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE QT_PREFIX
36 PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS LRCFLAGS QT_TRANSLATIONS QT_MOCSRCS QT_MOCHDRS
37endif
38PROPS_SINGLE += RCCTOOL
39PROPS_ACCUMULATE_R += RCCFLAGS QT_MODULES
40
41
42#
43# The QT4 SDK.
44#
45# This is implemented here rather than in sdks/QT4.kmk to enforce the global USES.
46# It also makes things easier to develop, with fewer files I mean.
47#
48## @todo the SDK might actually not be necessary as it turns out... For now it servers
49# a purpose if the host differs from the target, in theory at least.
50SDK_QT4 = Qt4
51
52# SDK Specific Properties
53ifndef PATH_SDK_QT4
54 PATH_SDK_QT4 := $(firstword $(rsort $(wildcard $(PATH_DEVTOOLS_TRG)/qt/v4*)))
55 ifeq ($(PATH_SDK_QT4),)
56 # If target == host, try look for Qt in the various platform specific places.
57 ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
58 ifeq ($(KBUILD_TARGET),darwin)
59 PATH_SDK_QT4 := $(patsubst %/Frameworks/QtCore.framework/Versions/4,%,$(firstword $(wildcard /Library/Frameworks/QtCore.framework/Versions/4)))
60 else ifeq ($(KBUILD_TARGET),win)
61 # No idea here yet...
62 else
63 # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT4_LIB* stuff if it doesn't work.
64 PATH_SDK_QT4 := $(patsubst %/bin/qt3to4,%,$(firstword $(wildcard /usr/bin/qt3to4 /usr/local/bin/qt3to4 /usr/qt/4/bin/qt3to4 /usr/share/qt4/bin/qt3to4)))
65 ifneq ($(PATH_SDK_QT4),)
66 ifeq ($(PATH_SDK_QT4_INC),)
67 PATH_SDK_QT4_INC := $(patsubst %/QtCore/qglobal.h,%,$(firstword $(wildcard $(PATH_SDK_QT4)/include/QtCore/qglobal.h $(PATH_SDK_QT4)/include/qt4/QtCore/qglobal.h /usr/include/qt4/QtCore/qtglobal.h)))
68 endif
69 ifeq ($(PATH_SDK_QT4_LIB.x86),)
70 PATH_SDK_QT4_LIB.x86 := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
71 $(PATH_SDK_QT4)/lib32/libQtCore$(SUFF_DLL) \
72 $(PATH_SDK_QT4)/lib32/qt4/libQtCore$(SUFF_DLL) \
73 /usr/lib32/libQtCore$(SUFF_DLL) \
74 /usr/lib32/qt4/libQtCore$(SUFF_DLL) \
75 /usr/local/lib32/libQtCore$(SUFF_DLL) \
76 /usr/local/lib32/qt4/libQtCore$(SUFF_DLL) \
77 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
78 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
79 )))
80 endif
81 ifeq ($(PATH_SDK_QT4_LIB.amd64),)
82 PATH_SDK_QT4_LIB.amd64 := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
83 $(PATH_SDK_QT4)/lib64/libQtCore$(SUFF_DLL) \
84 $(PATH_SDK_QT4)/lib64/qt4/libQtCore$(SUFF_DLL) \
85 $(PATH_SDK_QT4)/lib/amd64/libQtCore$(SUFF_DLL) \
86 /usr/lib64/libQtCore$(SUFF_DLL) \
87 /usr/lib64/qt4/libQtCore$(SUFF_DLL) \
88 /usr/lib/amd64/libQtCore$(SUFF_DLL) \
89 /usr/local/lib64/libQtCore$(SUFF_DLL) \
90 /usr/local/lib64/qt4/libQtCore$(SUFF_DLL) \
91 /usr/local/lib/amd64/libQtCore$(SUFF_DLL) \
92 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
93 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
94 )))
95 endif
96 ifeq ($(PATH_SDK_QT4_LIB),)
97 PATH_SDK_QT4_LIB := $(PATH_SDK_QT4_LIB.$(KBUILD_TARGET))
98 ifeq ($(PATH_SDK_QT4_LIB),)
99 PATH_SDK_QT4_LIB := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
100 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
101 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
102 /usr/lib/libQtCore$(SUFF_DLL) \
103 /usr/lib/qt4/libQtCore$(SUFF_DLL) \
104 /usr/local/lib/libQtCore$(SUFF_DLL) \
105 /usr/local/lib/qt4/libQtCore$(SUFF_DLL) \
106 )))
107 endif
108 endif
109 endif
110 endif # Unices
111 endif
112 # Found it?
113 ifeq ($(PATH_SDK_QT4),)
114 $(warning kBuild: Couldn't find the Qt4 headers and libaries...)
115 PATH_SDK_QT4 := $(PATH_DEVTOOLS_TRG)/qt/not-found
116 endif
117 endif
118else
119 # Resolve any fancy stuff once and for all.
120 PATH_SDK_QT4 := $(PATH_SDK_QT4)
121endif
122
123# Libraries can be in either Frameworks or lib depending on how you
124# build it on the mac. The .dmg installs into Frameworks but builds into lib.
125ifeq ($(KBUILD_TARGET),darwin)
126 ifndef PATH_SDK_QT4_LIB
127 ifneq ($(wildcard $(PATH_SDK_QT4)/Frameworks),)
128 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/Frameworks
129 else
130 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/lib
131 endif
132 endif
133else
134 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/lib
135 PATH_SDK_QT4_INC ?= $(PATH_SDK_QT4)/include
136endif
137
138# The bits that kBuild picks up.
139# (nothing here)
140
141
142#
143# The QT4 tool.
144#
145# This is implemented here rather than in tools/QT4.kmk to enforce the global USES.
146# It also makes things easier to develop, with fewer files I mean.
147#
148TOOL_QT4 = Qt4
149
150# Tool Specific Properties
151ifndef PATH_TOOL_QT4
152 PATH_TOOL_QT4 := $(firstword $(rsort $(wildcard $(PATH_DEVTOOLS_BLD)/qt/v4*)))
153 ifeq ($(PATH_TOOL_QT4),)
154 PATH_TOOL_QT4 := $(patsubst %/bin/qt3to4,%,$(firstword $(wildcard /usr/lib/qt4/bin/qt3to4 /usr/qt/4/bin/qt3to4 /usr/share/qt4/bin/qt3to4 /usr/local/bin/qt3to4 /usr/bin/qt3to4)))
155 endif
156 # If not found, we'll enter the 'pathless' mode.
157else
158 # Resolve any fancy stuff once and for all.
159 PATH_TOOL_QT4 := $(PATH_TOOL_QT4)
160endif
161ifneq ($(PATH_TOOL_QT4),)
162 PATH_TOOL_QT4_BIN ?= $(PATH_TOOL_QT4)/bin
163 TOOL_QT4_MOC ?= $(PATH_TOOL_QT4_BIN)/moc$(HOST_SUFF_EXE)
164 TOOL_QT4_UIC ?= $(PATH_TOOL_QT4_BIN)/uic$(HOST_SUFF_EXE)
165 TOOL_QT4_RCC ?= $(PATH_TOOL_QT4_BIN)/rcc$(HOST_SUFF_EXE)
166 TOOL_QT4_LRC ?= $(PATH_TOOL_QT4_BIN)/lrelease$(HOST_SUFF_EXE)
167 TOOL_QT4_LUPDATE ?= $(PATH_TOOL_QT4_BIN)/lupdate$(HOST_SUFF_EXE)
168else
169 # Pathless, relies on the environment.
170 TOOL_QT4_MOC ?= moc$(HOST_SUFF_EXE)
171 TOOL_QT4_UIC ?= uic$(HOST_SUFF_EXE)
172 TOOL_QT4_RCC ?= rcc$(HOST_SUFF_EXE)
173 TOOL_QT4_LRC ?= lrelease$(HOST_SUFF_EXE)
174 TOOL_QT4_LUPDATE ?= lupdate$(HOST_SUFF_EXE)
175endif
176
177# General Properties used by kBuild and/or units/qt.kmk
178TOOL_QT4_MOCFLAGS ?=
179TOOL_QT4_MOCINCS ?=
180TOOL_QT4_MOCDEFS ?=
181TOOL_QT4_MOCDEFS.darwin ?= __APPLE__ __GNUC__
182TOOL_QT4_MOCDEFS.solaris ?= __sun
183TOOL_QT4_MOCDEFS.win.amd64 ?= WIN64
184TOOL_QT4_MOCDEFS.win.x86 ?= WIN32
185
186
187## MOC a C++ source file.
188# @param $(target) Normalized main target name.
189# @param $(source) Source filename (relative).
190# @param $(out) Object file name. This shall be (re)created by the compilation.
191# @param $(dep) Dependcy file. This may be (re)created by the compilation.
192# @param $(flags) Flags.
193# @param $(defs) Definitions.
194# @param $(incs) Includes.
195# @param $(outbase) Output basename (full). Use this for list files and such.
196#
197TOOL_QT4_MOC_CPP_DEPEND =
198TOOL_QT4_MOC_CPP_DEPORD =
199TOOL_QT4_MOC_CPP_OUTPUT =
200TOOL_QT4_MOC_CPP_OUTPUT_MAYBE =
201define TOOL_QT4_MOC_CPP_CMDS
202 $(QUIET)$(TOOL_QT4_MOC)\
203 $(flags)\
204 $(addprefix -I, $(incs))\
205 $(addprefix -D, $(defs))\
206 -o $(out)\
207 $(source)
208endef
209
210## MOC a C++ header file.
211# @param $(target) Normalized main target name.
212# @param $(source) Source filename (relative).
213# @param $(out) Object file name. This shall be (re)created by the compilation.
214# @param $(dep) Dependcy file. This may be (re)created by the compilation.
215# @param $(flags) Flags.
216# @param $(defs) Definitions.
217# @param $(incs) Includes.
218# @param $(outbase) Output basename (full). Use this for list files and such.
219#
220TOOL_QT4_MOC_HPP_DEPEND =
221TOOL_QT4_MOC_HPP_DEPORD =
222TOOL_QT4_MOC_HPP_OUTPUT =
223TOOL_QT4_MOC_HPP_OUTPUT_MAYBE =
224define TOOL_QT4_MOC_HPP_CMDS
225 $(QUIET)$(TOOL_QT4_MOC)\
226 $(flags)\
227 $(addprefix -I, $(incs))\
228 $(addprefix -D, $(defs))\
229 -o $(out)\
230 $(source)
231endef
232
233## Compile a Qt user interface file (.ui).
234# @param $(target) Normalized main target name.
235# @param $(source) Source filename (relative).
236# @param $(out) Object file name. This shall be (re)created by the compilation.
237# @param $(dep) Dependcy file. This may be (re)created by the compilation.
238# @param $(flags) Flags.
239# @param $(defs) Definitions.
240# @param $(incs) Includes.
241# @param $(outbase) Output basename (full). Use this for list files and such.
242#
243TOOL_QT4_UIC_UI_DEPEND =
244TOOL_QT4_UIC_UI_DEPORD =
245TOOL_QT4_UIC_UI_OUTPUT =
246TOOL_QT4_UIC_UI_OUTPUT_MAYBE =
247define TOOL_QT4_UIC_UI_CMDS
248 $(QUIET)$(TOOL_QT4_UIC)\
249 $(flags)\
250 -o $(out)\
251 $(source)
252endef
253
254## Compile a Qt resource file (.qrc).
255# @param $(target) Normalized main target name.
256# @param $(source) Source filename (relative).
257# @param $(out) Object file name. This shall be (re)created by the compilation.
258# @param $(dep) Dependcy file. This may be (re)created by the compilation.
259# @param $(flags) Flags.
260# @param $(defs) Definitions.
261# @param $(incs) Includes.
262# @param $(outbase) Output basename (full). Use this for list files and such.
263#
264# @remarks The sed script generating the dependency file is a bit naive.
265TOOL_QT4_RCC_QRC_DEPEND =
266TOOL_QT4_RCC_QRC_DEPORD =
267TOOL_QT4_RCC_QRC_OUTPUT =
268TOOL_QT4_RCC_QRC_OUTPUT_MAYBE =
269define TOOL_QT4_RCC_QRC_CMDS
270 $(QUIET)$(TOOL_QT4_RCC)\
271 $(flags)\
272 -o $(out)\
273 $(source)
274 $(APPEND) $(dep) '\'
275 $(APPEND) $(dep) '$(out): \'
276 $(APPEND) $(dep) '$(source) \'
277 $(SED) \
278 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
279 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
280 -e 's|^[^/]|$(abspathex $(dir $(source)),$(defpath))/&|' \
281 -e 's|$$$$| \\|' \
282 --append $(dep) \
283 $(source)
284 $(APPEND) $(dep)
285 $(SED) \
286 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
287 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
288 -e 's|^[^/]|$(abspathex $(dir $(source)),$(defpath))/&|' \
289 -e 's|$$$$|:\n|' \
290 --append $(dep) \
291 $(source)
292 $(APPEND) $(dep)
293endef
294
295## Compile a Qt translation file (.ts).
296# @param $(target) Normalized main target name.
297# @param $(source) Source filename (relative).
298# @param $(out) Object file name. This shall be (re)created by the compilation.
299# @param $(dep) Dependcy file. This may be (re)created by the compilation.
300# @param $(flags) Flags.
301# @param $(defs) Definitions.
302# @param $(incs) Includes.
303# @param $(outbase) Output basename (full). Use this for list files and such.
304#
305TOOL_QT4_LRC_TS_DEPEND =
306TOOL_QT4_LRC_TS_DEPORD =
307TOOL_QT4_LRC_TS_OUTPUT =
308TOOL_QT4_LRC_TS_OUTPUT_MAYBE =
309define TOOL_QT4_LRC_TS_CMDS
310 $(QUIET)$(TOOL_QT4_LRC)\
311 $(flags)\
312 $(source)\
313 -qm $(out)
314endef
315
316
317
318#
319#
320# Back to the Qt4 unit.
321#
322#
323
324
325## wrapper for the lrelease (LRC) command dependencies.
326ifndef NO_COMPILE_CMDS_DEPS
327 _UNIT_QT4_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
328else
329 _UNIT_QT4_LRC_CMDS_DEP =
330endif
331
332##
333# def_unit_qt4_target_pre_handle_translation helper that is expanded before evaluation.
334#
335# This is necessary to resolve reference to local variables before doing
336# assignments and setting up commands. They would otherwise be resolved
337# later in a different context and the result would be completely wrong.
338#
339define def_unit_qt4_target_pre_handle_translation_dx
340
341$(out) + $(more_output) +| $(maybe_output): \
342 $(deps) \
343 $(value _UNIT_QT4_LRC_CMDS_DEP) \
344 | \
345 $(orderdeps)
346 %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
347 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
348
349$(cmds)
350
351ifndef NO_COMPILE_CMDS_DEPS
352 %$$(QUIET2)$$(APPEND) '$(dep)'
353 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_'
354 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
355 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
356endif
357
358$(target)_OUT_FILES += $(out) $(more_output) $(maybe_output)
359$(target)-inst-nls_SOURCES += $(out)
360
361endef # def_unit_qt4_target_pre_handle_translation_dx
362
363##
364# Handle a source file listed in QT_TRANSLATIONS.
365#
366# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
367# to be translated into .qm files that are loadble by Qt.
368#
369# @remarks Invoked via $(evalvalctx ).
370define def_unit_qt4_target_pre_handle_translation
371local type := LRC
372
373# fetch the properties.
374local tool := $(kb-src-tool dummy_var)
375local qtnlsdir := $(PATH_$(target))/qtnls
376local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
377local out := $(outbase).qm
378local dep := $(out).dep
379local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
380local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
381local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
382
383# default path + source dep.
384ifneq ($(defpath),)
385local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
386local incs := $(abspathex $(incs),$($(target)_PATH))
387else
388local deps += $(source)
389endif
390
391# call the tool
392ifndef TOOL_$(tool)_LRC_TS_CMDS
393 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
394endif
395local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
396local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
397local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
398local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
399local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
400
401# generate the link rule and update some source and target variables.
402ifndef NO_COMPILE_CMDS_DEPS
403 $(eval includedep $(dep))
404endif
405$(eval $(def_unit_qt4_target_pre_handle_translation_dx))
406
407endef # def_unit_qt4_target_pre_handle_translation
408
409
410
411## wrapper for the UIC command dependencies.
412ifndef NO_COMPILE_CMDS_DEPS
413 _UNIT_QT4_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
414else
415 _UNIT_QT4_RCC_CMDS_DEP =
416endif
417
418##
419# def_unit_qt4_target_pre_handle_qrc helper that is expanded before evaluation.
420#
421# This is necessary to resolve reference to local variables before doing
422# assignments and setting up commands. They would otherwise be resolved
423# later in a different context and the result would be completely wrong.
424#
425define def_unit_qt4_target_pre_handle_rcc_dx
426
427$(out) +| $(realout) $(more_output) $(maybe_output): \
428 $(deps) \
429 $(value _UNIT_QT4_RCC_CMDS_DEP) \
430 | \
431 $(orderdeps)
432 %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
433 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
434
435$(cmds)
436
437 $(QUIET)$(CP) --changed -f $(out) $(realout)
438ifndef NO_COMPILE_CMDS_DEPS
439 %$$(QUIET2)$$(APPEND) '$(dep)'
440 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_'
441 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
442 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
443endif
444
445$(target)_INTERMEDIATES += $(realout)
446$(target)_GEN_SOURCES_ += $(realout)
447$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
448
449endef # def_unit_qt4_target_pre_handle_rcc_dx
450
451##
452# Source handler for .qrc sources (Qt resource files).
453#
454# @remarks $(evalvalctx me).
455define def_unit_qt4_src_handler_qrc
456local type := RCC
457
458# fetch the properties.
459local tool := $(kb-src-tool dummy_var)
460local qtrccdir := $(PATH_$(target))/qtrcc
461local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
462local out := $(outbase).tmp.gen.cpp
463local realout := $(outbase).gen.cpp
464local dep := $(realout).dep
465local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
466local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
467local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
468
469# default path + source dep.
470ifneq ($(defpath),)
471local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
472local incs := $(abspathex $(incs),$($(target)_PATH))
473else
474local deps += $(source)
475endif
476
477# call the tool
478ifndef TOOL_$(tool)_RCC_QRC_CMDS
479 $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
480endif
481local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
482local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
483local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
484local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
485local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
486
487# generate the link rule and update some source and target variables.
488ifndef NO_COMPILE_CMDS_DEPS
489 $(eval includedep $(dep))
490endif
491$(eval $(def_unit_qt4_target_pre_handle_rcc_dx))
492
493endef # def_unit_qt4_src_handler_qrc
494
495
496
497## wrapper for the UIC command dependencies.
498ifndef NO_COMPILE_CMDS_DEPS
499 _UNIT_QT4_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
500else
501 _UNIT_QT4_UIC_CMDS_DEP =
502endif
503
504##
505# def_unit_qt4_src_handler_ui 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_qt4_target_pre_handle_ui_dx
512
513$(out) +| $(realout) $(more_output) $(maybe_output): \
514 $(deps) \
515 $(value _UNIT_QT4_UIC_CMDS_DEP) \
516 | \
517 $(orderdeps)
518 %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
519 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
520
521$(cmds)
522
523 $(QUIET)$(CP) --changed -f $(out) $(realout)
524ifndef NO_COMPILE_CMDS_DEPS
525 %$$(QUIET2)$$(APPEND) '$(dep)'
526 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_'
527 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
528 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
529endif
530
531$(target)_INTERMEDIATES += $(realout)
532$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
533
534endef # def_unit_qt4_target_pre_handle_ui_dx
535
536##
537# Source handler for .ui sources.
538#
539# @remarks $(evalvalctx me).
540define def_unit_qt4_src_handler_ui
541local type := UIC
542
543# fetch the properties.
544local tool := $(kb-src-tool dummy_var)
545local qtuicdir := $(PATH_$(target))/qtuic
546local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
547local out := $(outbase).tmp.gen.h
548local realout := $(outbase).gen.h
549local dep := $(realout).dep
550local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
551local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
552local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
553
554# default path + source dep.
555ifneq ($(defpath),)
556local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
557local incs := $(abspathex $(incs),$($(target)_PATH))
558else
559local deps += $(source)
560endif
561
562# call the tool
563ifndef TOOL_$(tool)_UIC_UI_CMDS
564 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
565endif
566local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
567local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
568local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
569local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
570local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
571
572# generate the link rule and update some source and target variables.
573ifndef NO_COMPILE_CMDS_DEPS
574 $(eval includedep $(dep))
575endif
576$(eval $(def_unit_qt4_target_pre_handle_ui_dx))
577
578endef # def_unit_qt4_src_handler_ui
579
580
581
582## wrapper for the MOC command dependencies.
583ifndef NO_COMPILE_CMDS_DEPS
584 _UNIT_QT4_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
585else
586 _UNIT_QT4_MOC_HPP_CMDS_DEP =
587endif
588
589##
590# def_unit_qt4_target_pre_handle_moc_hdr helper that is expanded before evaluation.
591#
592# This is necessary to resolve reference to local variables before doing
593# assignments and setting up commands. They would otherwise be resolved
594# later in a different context and the result would be completely wrong.
595#
596define def_unit_qt4_target_pre_handle_moc_hdr_dx
597
598$(out) +| $(realout) $(more_output) $(maybe_output): \
599 $(deps) \
600 $(value _UNIT_QT4_MOC_HPP_CMDS_DEP) \
601 | \
602 $(orderdeps)
603 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
604 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
605
606$(cmds)
607
608 $(QUIET)$(CP) --changed -f $(out) $(realout)
609ifndef NO_COMPILE_CMDS_DEPS
610 %$$(QUIET2)$$(APPEND) '$(dep)'
611 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_'
612 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
613 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
614endif
615
616$(target)_INTERMEDIATES += $(realout)
617$(target)_GEN_SOURCES_ += $(realout)
618$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
619
620endef
621
622##
623# Handle a source file listed in QT_MOCHDRS.
624#
625# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
626# generate a .cpp file for each of them and add it to the generated
627# sources so that it's compiled and linked. (There is an alternative
628# way to do this where the .cpp file is included, this isn't currently
629# supported by this unit.)
630#
631# @remarks Invoked via $(evalvalctx ).
632define def_unit_qt4_target_pre_handle_moc_hdr
633local type := MOC
634
635# fetch the properties.
636local tool := $(kb-src-tool dummy_var)
637local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
638local out := $(outbase).tmp.cpp
639local realout := $(outbase).cpp
640local dep := $(realout).dep
641local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
642local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
643local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
644local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
645local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
646
647# default path + source dep.
648ifneq ($(defpath),)
649local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
650local incs := $(abspathex $(incs),$($(target)_PATH))
651else
652local deps += $(source)
653endif
654
655# call the tool
656ifndef TOOL_$(tool)_MOC_HPP_CMDS
657 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
658endif
659local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
660local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
661local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
662local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
663local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
664
665# generate the link rule and update some source and target variables.
666ifndef NO_COMPILE_CMDS_DEPS
667 $(eval includedep $(dep))
668endif
669$(eval $(def_unit_qt4_target_pre_handle_moc_hdr_dx))
670
671endef # def_unit_qt4_target_pre_handle_moc_hdr
672
673
674## wrapper for the MOC command dependencies.
675ifndef NO_COMPILE_CMDS_DEPS
676 _UNIT_QT4_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
677else
678 _UNIT_QT4_MOC_CPP_CMDS_DEP =
679endif
680
681##
682# def_unit_qt4_target_pre_handle_moc_src helper that is expanded before evaluation.
683#
684# This is necessary to resolve reference to local variables before doing
685# assignments and setting up commands. They would otherwise be resolved
686# later in a different context and the result would be completely wrong.
687#
688define def_unit_qt4_target_pre_handle_moc_src_dx
689
690$(out) +| $(realout) $(more_output) $(maybe_output): \
691 $(deps) \
692 $(value _UNIT_QT4_MOC_CPP_CMDS_DEP) \
693 | \
694 $(orderdeps)
695 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
696 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
697
698$(cmds)
699
700 $(QUIET)$(CP) --changed -f $(out) $(realout)
701ifndef NO_COMPILE_CMDS_DEPS
702 %$$(QUIET2)$$(APPEND) '$(dep)'
703 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_'
704 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
705 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
706endif
707
708$(target)_INTERMEDIATES += $(realout)
709$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
710
711endef
712
713##
714# Handle a source file listed in QT_MOCSRCS.
715#
716# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
717# a .moc file that we're expected to generate here.
718#
719# @remarks Invoked via $(evalvalctx ).
720define def_unit_qt4_target_pre_handle_moc_src
721local type := MOC
722
723# fetch the properties.
724local tool := $(kb-src-tool dummy_var)
725local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
726local out := $(outbase).tmp.moc
727local realout := $(outbase).moc
728local dep := $(realout).dep
729local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
730local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
731local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
732local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
733local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
734
735# default path + source dep.
736ifneq ($(defpath),)
737local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
738local incs := $(abspathex $(incs),$($(target)_PATH))
739else
740local deps += $(source)
741endif
742
743# call the tool
744ifndef TOOL_$(tool)_MOC_CPP_CMDS
745 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
746endif
747local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
748local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
749local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
750local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
751local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
752
753# generate the link rule and update some source and target variables.
754ifndef NO_COMPILE_CMDS_DEPS
755 $(eval includedep $(dep))
756endif
757$(eval $(def_unit_qt4_target_pre_handle_moc_src_dx))
758
759endef # def_unit_qt4_target_pre_handle_moc_src
760
761
762##
763# Adds sources containing Q_OBJECT to QT_MOCSRCS.
764define def_unit_qt4_target_pre_cpp_source
765ifneq ($(file-size $(source)),-1)
766 ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
767 $(eval $(target)_QT_MOCSRCS += $(source))
768 endif
769endif
770endef # def_unit_qt4_target_pre_cpp_source
771
772##
773# Invoked early in the processing of a target that uses the Qt unit.
774#
775# It will append the qt source handlers to the target (.h, .ui, .ts,
776# .png, .bmp, .gif).
777#
778# It will then check all the C++ sources and check which needs
779# a .moc files and generate rules and dependencies fofor these
780#
781define def_unit_qt4_target_pre
782
783# Make QTTOOL the default for the specific Qt tools instead of TOOL.
784ifneq ($($(target)_QTTOOL),)
785 ifeq ($($(target)_MOCTOOL),)
786 $(target)_MOCTOOL := $($(target)_QTTOOL)
787 endif
788 ifeq ($($(target)_UICTOOL),)
789 $(target)_UICTOOL := $($(target)_QTTOOL)
790 endif
791 ifeq ($($(target)_RCCTOOL),)
792 $(target)_RCCTOOL := $($(target)_QTTOOL)
793 endif
794 ifeq ($($(target)_LRCTOOL),)
795 $(target)_LRCTOOL := $($(target)_QTTOOL)
796 endif
797endif
798
799# Deal with QT_MODULES and QT_PREFIX.
800local qt_modules := \
801 $($(target)_QT_MODULES.$(_bld_trg)) \
802 $($(target)_QT_MODULES.$(_bld_trg_arch)) \
803 $($(target)_QT_MODULES.$(_bld_trg).$(_bld_trg_arch)) \
804 $($(target)_QT_MODULES.$(_bld_trg_cpu)) \
805 $($(target)_QT_MODULES.$(_bld_type)) \
806 $($(target)_QT_MODULES)
807local qt_prefix := $(firstword \
808 $($(target)_QT_PREFIX.$(_bld_trg)) \
809 $($(target)_QT_PREFIX.$(_bld_trg_arch)) \
810 $($(target)_QT_PREFIX.$(_bld_trg).$(_bld_trg_arch)) \
811 $($(target)_QT_PREFIX.$(_bld_trg_cpu)) \
812 $($(target)_QT_PREFIX.$(_bld_type)) \
813 $($(target)_QT_PREFIX))
814ifeq ($(bld_trg),darwin)
815 # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
816 $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT4_LIB) )
817 $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT4_LIB) $(addprefix -framework Qt$(qt_prefix),$(qt_modules)) )
818 $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module).framework/Versions/4/Headers) )
819else
820 ifeq ($(bld_trg),win)
821 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)4$(SUFF_LIB)) )
822 ifeq ($(tool_do),LINK_PROGRAM)
823 $(eval $(target)_LIBS += $(PATH_SDK_QT4_LIB)/$(qt_prefix)qtmain$(SUFF_LIB) )
824 endif
825 else
826 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/lib$(qt_prefix)Qt$(module)$(SUFF_DLL)) )
827 endif
828 $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT4_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT4_INC) )
829endif
830$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
831
832
833# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
834# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
835ifndef $(target)_QT_MOCSRCS
836 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
837 $($(target)_SOURCES.$(_bld_trg)) \
838 $($(target)_SOURCES.$(_bld_trg_arch)) \
839 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
840 $($(target)_SOURCES.$(_bld_trg_cpu)) \
841 $($(target)_SOURCES.$(_bld_type)) \
842 $($(target)_SOURCES) \
843 ), $(evalval def_unit_qt4_target_pre_cpp_source))
844endif
845
846# Install source handlers for .ui files.
847$(target)_SRC_HANDLERS += \
848 .ui:def_unit_qt4_src_handler_ui \
849 .UI:def_unit_qt4_src_handler_ui \
850 .qrc:def_unit_qt4_src_handler_qrc \
851 .qrc:def_unit_qt4_src_handler_qrc
852
853# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
854local qtmocdir := $(PATH_$(target))/qtmoc
855local qtuicdir := $(PATH_$(target))/qtuic
856local qtrccdir := $(PATH_$(target))/qtrcc
857local qtnlsdir := $(PATH_$(target))/qtnls
858$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
859$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
860
861# Deal with QT_MOCSRCS.
862$(foreach source, \
863 $($(target)_QT_MOCSRCS.$(_bld_trg)) \
864 $($(target)_QT_MOCSRCS.$(_bld_trg_arch)) \
865 $($(target)_QT_MOCSRCS.$(_bld_trg).$(_bld_trg_arch)) \
866 $($(target)_QT_MOCSRCS.$(_bld_trg_cpu)) \
867 $($(target)_QT_MOCSRCS.$(_bld_type)) \
868 $($(target)_QT_MOCSRCS) \
869 , $(evalvalctx def_unit_qt4_target_pre_handle_moc_src))
870
871# Deal with QT_MOCHDRS.
872$(foreach source, \
873 $($(target)_QT_MOCHDRS.$(_bld_trg)) \
874 $($(target)_QT_MOCHDRS.$(_bld_trg_arch)) \
875 $($(target)_QT_MOCHDRS.$(_bld_trg).$(_bld_trg_arch)) \
876 $($(target)_QT_MOCHDRS.$(_bld_trg_cpu)) \
877 $($(target)_QT_MOCHDRS.$(_bld_type)) \
878 $($(target)_QT_MOCHDRS) \
879 , $(evalvalctx def_unit_qt4_target_pre_handle_moc_hdr))
880
881# Deal with QT_TRANSLATIONS.
882# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
883local translations := \
884 $($(target)_QT_TRANSLATIONS.$(_bld_trg)) \
885 $($(target)_QT_TRANSLATIONS.$(_bld_trg_arch)) \
886 $($(target)_QT_TRANSLATIONS.$(_bld_trg).$(_bld_trg_arch)) \
887 $($(target)_QT_TRANSLATIONS.$(_bld_trg_cpu)) \
888 $($(target)_QT_TRANSLATIONS.$(_bld_type)) \
889 $($(target)_QT_TRANSLATIONS)
890ifneq ($(strip $(translations)),)
891 local expr := _ALL_INSTALLS += $(target)-inst-nls
892 $(eval $(expr))
893 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
894 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
895 else
896 $(target)-inst-nls_MODE := 0644
897 endif
898 ifdef $(target)_QT_TRANSLATIONS_INST
899 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
900 endif
901 $(target)-inst-nls_SOURCES :=
902 $(foreach source, $(translations)\
903 , $(evalvalctx def_unit_qt4_target_pre_handle_translation))
904endif
905
906endef # def_unit_qt4_target_pre
907
Note: See TracBrowser for help on using the repository browser.