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

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

qt4.kmk: Better PATH_TOOL_QT4 guessing (fedora 8).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 30.4 KB
Line 
1# $Id: qt4.kmk 1687 2008-08-22 20:39:30Z 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) '$(source): \'
275 $(SED) \
276 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
277 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
278 -e 's|^[^/]|$(abspathex $(dir $(source)),$(defpath))/&|' \
279 -e 's|$$$$| \\|' \
280 --append $(dep) \
281 $(source)
282 $(APPEND) $(dep)
283 $(SED) \
284 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
285 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
286 -e 's|^[^/]|$(abspathex $(dir $(source)),$(defpath))/&|' \
287 -e 's|$$$$|:\n|' \
288 --append $(dep) \
289 $(source)
290 $(APPEND) $(dep)
291endef
292
293## Compile a Qt translation file (.ts).
294# @param $(target) Normalized main target name.
295# @param $(source) Source filename (relative).
296# @param $(out) Object file name. This shall be (re)created by the compilation.
297# @param $(dep) Dependcy file. This may be (re)created by the compilation.
298# @param $(flags) Flags.
299# @param $(defs) Definitions.
300# @param $(incs) Includes.
301# @param $(outbase) Output basename (full). Use this for list files and such.
302#
303TOOL_QT4_LRC_TS_DEPEND =
304TOOL_QT4_LRC_TS_DEPORD =
305TOOL_QT4_LRC_TS_OUTPUT =
306TOOL_QT4_LRC_TS_OUTPUT_MAYBE =
307define TOOL_QT4_LRC_TS_CMDS
308 $(QUIET)$(TOOL_QT4_LRC)\
309 $(flags)\
310 $(source)\
311 -qm $(out)
312endef
313
314
315
316#
317#
318# Back to the Qt4 unit.
319#
320#
321
322
323## wrapper for the lrelease (LRC) command dependencies.
324ifndef NO_COMPILE_CMDS_DEPS
325 _UNIT_QT4_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
326else
327 _UNIT_QT4_LRC_CMDS_DEP =
328endif
329
330##
331# def_unit_qt4_target_pre_handle_translation helper that is expanded before evaluation.
332#
333# This is necessary to resolve reference to local variables before doing
334# assignments and setting up commands. They would otherwise be resolved
335# later in a different context and the result would be completely wrong.
336#
337define def_unit_qt4_target_pre_handle_translation_dx
338
339$(out) + $(more_output) +| $(maybe_output): \
340 $(deps) \
341 $(value _UNIT_QT4_LRC_CMDS_DEP) \
342 | \
343 $(orderdeps)
344 %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
345 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
346
347$(cmds)
348
349ifndef NO_COMPILE_CMDS_DEPS
350 %$$(QUIET2)$$(APPEND) '$(dep)'
351 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_'
352 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
353 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
354endif
355
356$(target)_OUT_FILES += $(out) $(more_output) $(maybe_output)
357$(target)-inst-nls_SOURCES += $(out)
358
359endef # def_unit_qt4_target_pre_handle_translation_dx
360
361##
362# Handle a source file listed in QT_TRANSLATIONS.
363#
364# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
365# to be translated into .qm files that are loadble by Qt.
366#
367# @remarks Invoked via $(evalvalctx ).
368define def_unit_qt4_target_pre_handle_translation
369local type := LRC
370
371# fetch the properties.
372local tool := $(kb-src-tool dummy_var)
373local qtnlsdir := $(PATH_$(target))/qtnls
374local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
375local out := $(outbase).qm
376local dep := $(out).dep
377local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
378local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
379local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
380
381# default path + source dep.
382ifneq ($(defpath),)
383local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
384local incs := $(abspathex $(incs),$($(target)_PATH))
385else
386local deps += $(source)
387endif
388
389# call the tool
390ifndef TOOL_$(tool)_LRC_TS_CMDS
391 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
392endif
393local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
394local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
395local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
396local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
397local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
398
399# generate the link rule and update some source and target variables.
400ifndef NO_COMPILE_CMDS_DEPS
401 $(eval includedep $(dep))
402endif
403$(eval $(def_unit_qt4_target_pre_handle_translation_dx))
404
405endef # def_unit_qt4_target_pre_handle_translation
406
407
408
409## wrapper for the UIC command dependencies.
410ifndef NO_COMPILE_CMDS_DEPS
411 _UNIT_QT4_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
412else
413 _UNIT_QT4_RCC_CMDS_DEP =
414endif
415
416##
417# def_unit_qt4_target_pre_handle_qrc helper that is expanded before evaluation.
418#
419# This is necessary to resolve reference to local variables before doing
420# assignments and setting up commands. They would otherwise be resolved
421# later in a different context and the result would be completely wrong.
422#
423define def_unit_qt4_target_pre_handle_rcc_dx
424
425$(out) +| $(realout) $(more_output) $(maybe_output): \
426 $(deps) \
427 $(value _UNIT_QT4_RCC_CMDS_DEP) \
428 | \
429 $(orderdeps)
430 %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
431 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
432
433$(cmds)
434
435 $(QUIET)$(CP) --changed -f $(out) $(realout)
436ifndef NO_COMPILE_CMDS_DEPS
437 %$$(QUIET2)$$(APPEND) '$(dep)'
438 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_'
439 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
440 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
441endif
442
443$(target)_INTERMEDIATES += $(realout)
444$(target)_GEN_SOURCES_ += $(realout)
445$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
446
447endef # def_unit_qt4_target_pre_handle_rcc_dx
448
449##
450# Source handler for .qrc sources (Qt resource files).
451#
452# @remarks $(evalvalctx me).
453define def_unit_qt4_src_handler_qrc
454local type := RCC
455
456# fetch the properties.
457local tool := $(kb-src-tool dummy_var)
458local qtrccdir := $(PATH_$(target))/qtrcc
459local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
460local out := $(outbase).tmp.gen.cpp
461local realout := $(outbase).gen.cpp
462local dep := $(realout).dep
463local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
464local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
465local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
466
467# default path + source dep.
468ifneq ($(defpath),)
469local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
470local incs := $(abspathex $(incs),$($(target)_PATH))
471else
472local deps += $(source)
473endif
474
475# call the tool
476ifndef TOOL_$(tool)_RCC_QRC_CMDS
477 $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
478endif
479local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
480local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
481local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
482local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
483local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
484
485# generate the link rule and update some source and target variables.
486ifndef NO_COMPILE_CMDS_DEPS
487 $(eval includedep $(dep))
488endif
489$(eval $(def_unit_qt4_target_pre_handle_rcc_dx))
490
491endef # def_unit_qt4_src_handler_qrc
492
493
494
495## wrapper for the UIC command dependencies.
496ifndef NO_COMPILE_CMDS_DEPS
497 _UNIT_QT4_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
498else
499 _UNIT_QT4_UIC_CMDS_DEP =
500endif
501
502##
503# def_unit_qt4_src_handler_ui helper that is expanded before evaluation.
504#
505# This is necessary to resolve reference to local variables before doing
506# assignments and setting up commands. They would otherwise be resolved
507# later in a different context and the result would be completely wrong.
508#
509define def_unit_qt4_target_pre_handle_ui_dx
510
511$(out) +| $(realout) $(more_output) $(maybe_output): \
512 $(deps) \
513 $(value _UNIT_QT4_UIC_CMDS_DEP) \
514 | \
515 $(orderdeps)
516 %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
517 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
518
519$(cmds)
520
521 $(QUIET)$(CP) --changed -f $(out) $(realout)
522ifndef NO_COMPILE_CMDS_DEPS
523 %$$(QUIET2)$$(APPEND) '$(dep)'
524 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_'
525 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
526 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
527endif
528
529$(target)_INTERMEDIATES += $(realout)
530$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
531
532endef # def_unit_qt4_target_pre_handle_ui_dx
533
534##
535# Source handler for .ui sources.
536#
537# @remarks $(evalvalctx me).
538define def_unit_qt4_src_handler_ui
539local type := UIC
540
541# fetch the properties.
542local tool := $(kb-src-tool dummy_var)
543local qtuicdir := $(PATH_$(target))/qtuic
544local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
545local out := $(outbase).tmp.gen.h
546local realout := $(outbase).gen.h
547local dep := $(realout).dep
548local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
549local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
550local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
551
552# default path + source dep.
553ifneq ($(defpath),)
554local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
555local incs := $(abspathex $(incs),$($(target)_PATH))
556else
557local deps += $(source)
558endif
559
560# call the tool
561ifndef TOOL_$(tool)_UIC_UI_CMDS
562 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
563endif
564local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
565local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
566local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
567local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
568local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
569
570# generate the link rule and update some source and target variables.
571ifndef NO_COMPILE_CMDS_DEPS
572 $(eval includedep $(dep))
573endif
574$(eval $(def_unit_qt4_target_pre_handle_ui_dx))
575
576endef # def_unit_qt4_src_handler_ui
577
578
579
580## wrapper for the MOC command dependencies.
581ifndef NO_COMPILE_CMDS_DEPS
582 _UNIT_QT4_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
583else
584 _UNIT_QT4_MOC_HPP_CMDS_DEP =
585endif
586
587##
588# def_unit_qt4_target_pre_handle_moc_hdr helper that is expanded before evaluation.
589#
590# This is necessary to resolve reference to local variables before doing
591# assignments and setting up commands. They would otherwise be resolved
592# later in a different context and the result would be completely wrong.
593#
594define def_unit_qt4_target_pre_handle_moc_hdr_dx
595
596$(out) +| $(realout) $(more_output) $(maybe_output): \
597 $(deps) \
598 $(value _UNIT_QT4_MOC_HPP_CMDS_DEP) \
599 | \
600 $(orderdeps)
601 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
602 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
603
604$(cmds)
605
606 $(QUIET)$(CP) --changed -f $(out) $(realout)
607ifndef NO_COMPILE_CMDS_DEPS
608 %$$(QUIET2)$$(APPEND) '$(dep)'
609 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_'
610 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
611 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
612endif
613
614$(target)_INTERMEDIATES += $(realout)
615$(target)_GEN_SOURCES_ += $(realout)
616$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
617
618endef
619
620##
621# Handle a source file listed in QT_MOCHDRS.
622#
623# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
624# generate a .cpp file for each of them and add it to the generated
625# sources so that it's compiled and linked. (There is an alternative
626# way to do this where the .cpp file is included, this isn't currently
627# supported by this unit.)
628#
629# @remarks Invoked via $(evalvalctx ).
630define def_unit_qt4_target_pre_handle_moc_hdr
631local type := MOC
632
633# fetch the properties.
634local tool := $(kb-src-tool dummy_var)
635local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
636local out := $(outbase).tmp.cpp
637local realout := $(outbase).cpp
638local dep := $(realout).dep
639local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
640local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
641local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
642local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
643local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
644
645# default path + source dep.
646ifneq ($(defpath),)
647local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
648local incs := $(abspathex $(incs),$($(target)_PATH))
649else
650local deps += $(source)
651endif
652
653# call the tool
654ifndef TOOL_$(tool)_MOC_HPP_CMDS
655 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
656endif
657local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
658local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
659local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
660local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
661local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
662
663# generate the link rule and update some source and target variables.
664ifndef NO_COMPILE_CMDS_DEPS
665 $(eval includedep $(dep))
666endif
667$(eval $(def_unit_qt4_target_pre_handle_moc_hdr_dx))
668
669endef # def_unit_qt4_target_pre_handle_moc_hdr
670
671
672## wrapper for the MOC command dependencies.
673ifndef NO_COMPILE_CMDS_DEPS
674 _UNIT_QT4_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
675else
676 _UNIT_QT4_MOC_CPP_CMDS_DEP =
677endif
678
679##
680# def_unit_qt4_target_pre_handle_moc_src helper that is expanded before evaluation.
681#
682# This is necessary to resolve reference to local variables before doing
683# assignments and setting up commands. They would otherwise be resolved
684# later in a different context and the result would be completely wrong.
685#
686define def_unit_qt4_target_pre_handle_moc_src_dx
687
688$(out) +| $(realout) $(more_output) $(maybe_output): \
689 $(deps) \
690 $(value _UNIT_QT4_MOC_CPP_CMDS_DEP) \
691 | \
692 $(orderdeps)
693 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
694 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
695
696$(cmds)
697
698 $(QUIET)$(CP) --changed -f $(out) $(realout)
699ifndef NO_COMPILE_CMDS_DEPS
700 %$$(QUIET2)$$(APPEND) '$(dep)'
701 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_'
702 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
703 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
704endif
705
706$(target)_INTERMEDIATES += $(realout)
707$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
708
709endef
710
711##
712# Handle a source file listed in QT_MOCSRCS.
713#
714# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
715# a .moc file that we're expected to generate here.
716#
717# @remarks Invoked via $(evalvalctx ).
718define def_unit_qt4_target_pre_handle_moc_src
719local type := MOC
720
721# fetch the properties.
722local tool := $(kb-src-tool dummy_var)
723local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
724local out := $(outbase).tmp.moc
725local realout := $(outbase).moc
726local dep := $(realout).dep
727local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
728local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
729local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
730local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
731local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
732
733# default path + source dep.
734ifneq ($(defpath),)
735local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
736local incs := $(abspathex $(incs),$($(target)_PATH))
737else
738local deps += $(source)
739endif
740
741# call the tool
742ifndef TOOL_$(tool)_MOC_CPP_CMDS
743 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
744endif
745local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
746local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
747local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
748local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
749local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
750
751# generate the link rule and update some source and target variables.
752ifndef NO_COMPILE_CMDS_DEPS
753 $(eval includedep $(dep))
754endif
755$(eval $(def_unit_qt4_target_pre_handle_moc_src_dx))
756
757endef # def_unit_qt4_target_pre_handle_moc_src
758
759
760##
761# Adds sources containing Q_OBJECT to QT_MOCSRCS.
762define def_unit_qt4_target_pre_cpp_source
763ifneq ($(file-size $(source)),-1)
764 ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
765 $(eval $(target)_QT_MOCSRCS += $(source))
766 endif
767endif
768endef # def_unit_qt4_target_pre_cpp_source
769
770##
771# Invoked early in the processing of a target that uses the Qt unit.
772#
773# It will append the qt source handlers to the target (.h, .ui, .ts,
774# .png, .bmp, .gif).
775#
776# It will then check all the C++ sources and check which needs
777# a .moc files and generate rules and dependencies fofor these
778#
779define def_unit_qt4_target_pre
780
781# Make QTTOOL the default for the specific Qt tools instead of TOOL.
782ifneq ($($(target)_QTTOOL),)
783 ifeq ($($(target)_MOCTOOL),)
784 $(target)_MOCTOOL := $($(target)_QTTOOL)
785 endif
786 ifeq ($($(target)_UICTOOL),)
787 $(target)_UICTOOL := $($(target)_QTTOOL)
788 endif
789 ifeq ($($(target)_RCCTOOL),)
790 $(target)_RCCTOOL := $($(target)_QTTOOL)
791 endif
792 ifeq ($($(target)_LRCTOOL),)
793 $(target)_LRCTOOL := $($(target)_QTTOOL)
794 endif
795endif
796
797# Deal with QT_MODULES and QT_PREFIX.
798local qt_modules := \
799 $($(target)_QT_MODULES.$(_bld_trg)) \
800 $($(target)_QT_MODULES.$(_bld_trg_arch)) \
801 $($(target)_QT_MODULES.$(_bld_trg).$(_bld_trg_arch)) \
802 $($(target)_QT_MODULES.$(_bld_trg_cpu)) \
803 $($(target)_QT_MODULES.$(_bld_type)) \
804 $($(target)_QT_MODULES)
805local qt_prefix := $(firstword \
806 $($(target)_QT_PREFIX.$(_bld_trg)) \
807 $($(target)_QT_PREFIX.$(_bld_trg_arch)) \
808 $($(target)_QT_PREFIX.$(_bld_trg).$(_bld_trg_arch)) \
809 $($(target)_QT_PREFIX.$(_bld_trg_cpu)) \
810 $($(target)_QT_PREFIX.$(_bld_type)) \
811 $($(target)_QT_PREFIX))
812ifeq ($(bld_trg),darwin)
813 # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
814 $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT4_LIB) )
815 $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT4_LIB) $(addprefix -framework Qt$(qt_prefix),$(qt_modules)) )
816 $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module).framework/Versions/4/Headers) )
817else
818 ifeq ($(bld_trg),win)
819 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)4$(SUFF_LIB)) )
820 ifeq ($(tool_do),LINK_PROGRAM)
821 $(eval $(target)_LIBS += $(PATH_SDK_QT4_LIB)/$(qt_prefix)qtmain$(SUFF_LIB) )
822 endif
823 else
824 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/lib$(qt_prefix)Qt$(module)$(SUFF_DLL)) )
825 endif
826 $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT4_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT4_INC) )
827endif
828$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
829
830
831# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
832# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
833ifndef $(target)_QT_MOCSRCS
834 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
835 $($(target)_SOURCES.$(_bld_trg)) \
836 $($(target)_SOURCES.$(_bld_trg_arch)) \
837 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
838 $($(target)_SOURCES.$(_bld_trg_cpu)) \
839 $($(target)_SOURCES.$(_bld_type)) \
840 $($(target)_SOURCES) \
841 ), $(evalval def_unit_qt4_target_pre_cpp_source))
842endif
843
844# Install source handlers for .ui files.
845$(target)_SRC_HANDLERS += \
846 .ui:def_unit_qt4_src_handler_ui \
847 .UI:def_unit_qt4_src_handler_ui \
848 .qrc:def_unit_qt4_src_handler_qrc \
849 .qrc:def_unit_qt4_src_handler_qrc
850
851# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
852local qtmocdir := $(PATH_$(target))/qtmoc
853local qtuicdir := $(PATH_$(target))/qtuic
854local qtrccdir := $(PATH_$(target))/qtrcc
855local qtnlsdir := $(PATH_$(target))/qtnls
856$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
857$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
858
859# Deal with QT_MOCSRCS.
860$(foreach source, \
861 $($(target)_QT_MOCSRCS.$(_bld_trg)) \
862 $($(target)_QT_MOCSRCS.$(_bld_trg_arch)) \
863 $($(target)_QT_MOCSRCS.$(_bld_trg).$(_bld_trg_arch)) \
864 $($(target)_QT_MOCSRCS.$(_bld_trg_cpu)) \
865 $($(target)_QT_MOCSRCS.$(_bld_type)) \
866 $($(target)_QT_MOCSRCS) \
867 , $(evalvalctx def_unit_qt4_target_pre_handle_moc_src))
868
869# Deal with QT_MOCHDRS.
870$(foreach source, \
871 $($(target)_QT_MOCHDRS.$(_bld_trg)) \
872 $($(target)_QT_MOCHDRS.$(_bld_trg_arch)) \
873 $($(target)_QT_MOCHDRS.$(_bld_trg).$(_bld_trg_arch)) \
874 $($(target)_QT_MOCHDRS.$(_bld_trg_cpu)) \
875 $($(target)_QT_MOCHDRS.$(_bld_type)) \
876 $($(target)_QT_MOCHDRS) \
877 , $(evalvalctx def_unit_qt4_target_pre_handle_moc_hdr))
878
879# Deal with QT_TRANSLATIONS.
880# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
881local translations := \
882 $($(target)_QT_TRANSLATIONS.$(_bld_trg)) \
883 $($(target)_QT_TRANSLATIONS.$(_bld_trg_arch)) \
884 $($(target)_QT_TRANSLATIONS.$(_bld_trg).$(_bld_trg_arch)) \
885 $($(target)_QT_TRANSLATIONS.$(_bld_trg_cpu)) \
886 $($(target)_QT_TRANSLATIONS.$(_bld_type)) \
887 $($(target)_QT_TRANSLATIONS)
888ifneq ($(strip $(translations)),)
889 local expr := _ALL_INSTALLS += $(target)-inst-nls
890 $(eval $(expr))
891 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
892 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
893 endif
894 ifdef $(target)_QT_TRANSLATIONS_INST
895 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
896 endif
897 $(target)-inst-nls_SOURCES :=
898 $(foreach source, $(translations)\
899 , $(evalvalctx def_unit_qt4_target_pre_handle_translation))
900endif
901
902endef # def_unit_qt4_target_pre
903
Note: See TracBrowser for help on using the repository browser.