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

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

qt4 unit: some qt -> qt4 fixes. separate the moc cmd deps.

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