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

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

unix wants lib prefix.

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