source: trunk/kBuild/units/qt3.kmk@ 1690

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

qt3,qt4: Set the nls installation mode to 0644 if no template was specified.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 24.9 KB
Line 
1# $Id: qt3.kmk 1688 2008-08-23 21:03:26Z bird $
2## @file
3# Qt 3 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_qt3
28 $(error kBuild: The qt3 unit was included twice!)
29endif
30UNIT_qt3 = qt3
31
32
33ifndef UNIT_qt4
34 # Add our target properties (same as qt4).
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 +=
39PROPS_ACCUMULATE_R += QT_IMAGES
40
41
42#
43# The QT3 SDK.
44#
45# This is implemented here rather than in sdks/QT3.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_QT3 = Qt3
51
52# SDK Specific Properties
53ifndef PATH_SDK_QT3
54 PATH_SDK_QT3 := $(firstword $(rsort $(wildcard $(PATH_DEVTOOLS_TRG)/qt/v3*)))
55 ifeq ($(PATH_SDK_QT3),)
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 # No idea here yet...
60 else ifeq ($(KBUILD_TARGET),os2)
61 # No idea here yet...
62 else ifeq ($(KBUILD_TARGET),win)
63 # No idea here yet...
64 else
65 # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT3_LIB* stuff if it doesn't work.
66 PATH_SDK_QT3 := $(patsubst %/bin/qm2ts,%,$(firstword $(wildcard /usr/bin/qm2ts /usr/local/bin/qm2ts /usr/qt/3/bin/qm2ts /usr/share/qt3/bin/qm2ts)))
67 ifneq ($(PATH_SDK_QT3),)
68 ifeq ($(PATH_SDK_QT3_INC),)
69 PATH_SDK_QT3_INC := $(patsubst %/private/qfiledefs_p.h,%,$(firstword $(wildcard $(PATH_SDK_QT3)/include/private/qfiledefs_p.h $(PATH_SDK_QT3)/include/qt3/private/qfiledefs_p.h /usr/include/qt3/private/qfiledefs_p.h)))
70 endif
71 ifeq ($(PATH_SDK_QT3_LIB.x86),)
72 PATH_SDK_QT3_LIB.x86 := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
73 $(PATH_SDK_QT3)/lib32/libqt-mt$(SUFF_DLL) \
74 $(PATH_SDK_QT3)/lib32/qt3/libqt-mt$(SUFF_DLL) \
75 /usr/lib32/libqt-mt$(SUFF_DLL) \
76 /usr/lib32/qt3/libqt-mt$(SUFF_DLL) \
77 /usr/local/lib32/libqt-mt$(SUFF_DLL) \
78 /usr/local/lib32/qt3/libqt-mt$(SUFF_DLL) \
79 $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
80 $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
81 )))
82 endif
83 ifeq ($(PATH_SDK_QT3_LIB.amd64),)
84 PATH_SDK_QT3_LIB.amd64 := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
85 $(PATH_SDK_QT3)/lib64/libqt-mt$(SUFF_DLL) \
86 $(PATH_SDK_QT3)/lib64/qt3/libqt-mt$(SUFF_DLL) \
87 $(PATH_SDK_QT3)/lib/amd64/libqt-mt$(SUFF_DLL) \
88 /usr/lib64/libqt-mt$(SUFF_DLL) \
89 /usr/lib64/qt3/libqt-mt$(SUFF_DLL) \
90 /usr/lib/amd64/libqt-mt$(SUFF_DLL) \
91 /usr/local/lib64/libqt-mt$(SUFF_DLL) \
92 /usr/local/lib64/qt3/libqt-mt$(SUFF_DLL) \
93 /usr/local/lib/amd64/libqt-mt$(SUFF_DLL) \
94 $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
95 $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
96 )))
97 endif
98 ifeq ($(PATH_SDK_QT3_LIB),)
99 PATH_SDK_QT3_LIB := $(PATH_SDK_QT3_LIB.$(KBUILD_TARGET))
100 ifeq ($(PATH_SDK_QT3_LIB),)
101 PATH_SDK_QT3_LIB := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
102 $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
103 $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
104 /usr/lib/libqt-mt$(SUFF_DLL) \
105 /usr/lib/qt3/libqt-mt$(SUFF_DLL) \
106 /usr/local/lib/libqt-mt$(SUFF_DLL) \
107 /usr/local/lib/qt3/libqt-mt$(SUFF_DLL) \
108 )))
109 endif
110 endif
111 endif
112 endif # Unices
113 endif
114 # Found it?
115 ifeq ($(PATH_SDK_QT3),)
116 $(warning kBuild: Couldn't find the Qt3 headers and libaries...)
117 PATH_SDK_QT3 := $(PATH_DEVTOOLS_TRG)/qt/not-found
118 endif
119 endif
120else
121 # Resolve any fancy stuff once and for all.
122 PATH_SDK_QT3 := $(PATH_SDK_QT3)
123endif
124
125# Libraries can be in either Frameworks or lib depending on how you
126# build it on the mac. The .dmg installs into Frameworks but builds into lib.
127PATH_SDK_QT3_LIB ?= $(PATH_SDK_QT3)/lib
128PATH_SDK_QT3_INC ?= $(PATH_SDK_QT3)/include
129
130# The bits that kBuild picks up.
131# (nothing here)
132
133
134#
135# The QT3 tool.
136#
137# This is implemented here rather than in tools/QT3.kmk to enforce the global USES.
138# It also makes things easier to develop, with fewer files I mean.
139#
140TOOL_QT3 = Qt3
141
142# Tool Specific Properties
143ifndef PATH_TOOL_QT3
144 PATH_TOOL_QT3 := $(firstword $(rsort $(wildcard $(PATH_DEVTOOLS_BLD)/qt/v3*)))
145 ifeq ($(PATH_TOOL_QT3),)
146 PATH_TOOL_QT3 := $(patsubst %/bin/qm2ts,%,$(firstword $(wildcard /usr/bin/qm2ts /usr/local/bin/qm2ts /usr/qt/3/bin/qm2ts)))
147 endif
148 # If not found, we'll enter the 'pathless' mode.
149else
150 # Resolve any fancy stuff once and for all.
151 PATH_TOOL_QT3 := $(PATH_TOOL_QT3)
152endif
153ifneq ($(PATH_TOOL_QT3),)
154 PATH_TOOL_QT3_BIN ?= $(PATH_TOOL_QT3)/bin
155 TOOL_QT3_MOC ?= $(PATH_TOOL_QT3_BIN)/moc$(HOST_SUFF_EXE)
156 TOOL_QT3_UIC ?= $(PATH_TOOL_QT3_BIN)/uic$(HOST_SUFF_EXE)
157 TOOL_QT3_LRC ?= $(PATH_TOOL_QT3_BIN)/lrelease$(HOST_SUFF_EXE)
158 TOOL_QT3_LUPDATE ?= $(PATH_TOOL_QT3_BIN)/lupdate$(HOST_SUFF_EXE)
159else
160 # Pathless, relies on the environment.
161 TOOL_QT3_MOC ?= moc$(HOST_SUFF_EXE)
162 TOOL_QT3_UIC ?= uic$(HOST_SUFF_EXE)
163 TOOL_QT3_LRC ?= lrelease$(HOST_SUFF_EXE)
164 TOOL_QT3_LUPDATE ?= lupdate$(HOST_SUFF_EXE)
165endif
166
167# General Properties used by kBuild and/or units/qt.kmk
168TOOL_QT3_MOCFLAGS ?=
169TOOL_QT3_UICFLAGS ?=
170TOOL_QT3_LRCFLAGS ?=
171
172
173## MOC a C++ source file.
174# @param $(target) Normalized main target name.
175# @param $(source) Source filename (relative).
176# @param $(out) Object file name. This shall be (re)created by the compilation.
177# @param $(dep) Dependcy file. This may be (re)created by the compilation.
178# @param $(flags) Flags.
179# @param $(outbase) Output basename (full). Use this for list files and such.
180#
181TOOL_QT3_MOC_CPP_DEPEND =
182TOOL_QT3_MOC_CPP_DEPORD =
183TOOL_QT3_MOC_CPP_OUTPUT =
184TOOL_QT3_MOC_CPP_OUTPUT_MAYBE =
185define TOOL_QT3_MOC_CPP_CMDS
186 $(QUIET)$(TOOL_QT3_MOC)\
187 $(flags)\
188 -o $(out)\
189 -i \
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 $(outbase) Output basename (full). Use this for list files and such.
200#
201TOOL_QT3_MOC_HPP_DEPEND =
202TOOL_QT3_MOC_HPP_DEPORD =
203TOOL_QT3_MOC_HPP_OUTPUT =
204TOOL_QT3_MOC_HPP_OUTPUT_MAYBE =
205define TOOL_QT3_MOC_HPP_CMDS
206 $(QUIET)$(TOOL_QT3_MOC)\
207 $(flags)\
208 -o $(out)\
209 $(source)
210endef
211
212## Compile a Qt user interface file (.ui).
213# @param $(target) Normalized main target name.
214# @param $(source) Source filename (relative).
215# @param $(out.cpp) The C++ source file to be generated.
216# @param $(out.h) The C++ header file to be generated.
217# @param $(dep) Dependcy file. This may be (re)created by the compilation.
218# @param $(flags) Flags.
219# @param $(outbase) Output basename (full). Use this for list files and such.
220#
221TOOL_QT3_UIC_UI_DEPEND =
222TOOL_QT3_UIC_UI_DEPORD =
223TOOL_QT3_UIC_UI_OUTPUT =
224TOOL_QT3_UIC_UI_OUTPUT_MAYBE =
225define TOOL_QT3_UIC_UI_CMDS
226 $(QUIET)$(TOOL_QT3_UIC)\
227 $(flags)\
228 -o $(out.h)\
229 $(source)
230 $(QUIET)$(TOOL_QT3_UIC)\
231 $(flags)\
232 -i $(out.h) \
233 -o $(out.cpp)\
234 $(source)
235endef
236
237## Compile a Qt translation file (.ts).
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#
247TOOL_QT3_LRC_TS_DEPEND =
248TOOL_QT3_LRC_TS_DEPORD =
249TOOL_QT3_LRC_TS_OUTPUT =
250TOOL_QT3_LRC_TS_OUTPUT_MAYBE =
251define TOOL_QT3_LRC_TS_CMDS
252 $(QUIET)$(TOOL_QT3_LRC)\
253 $(flags)\
254 $(source)\
255 -qm $(out)
256endef
257
258
259
260#
261#
262# Back to the Qt3 unit.
263#
264#
265
266
267## wrapper for the lrelease (LRC) command dependencies.
268ifndef NO_COMPILE_CMDS_DEPS
269 _UNIT_QT3_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
270else
271 _UNIT_QT3_LRC_CMDS_DEP =
272endif
273
274##
275# def_unit_qt3_target_pre_handle_translation helper that is expanded before evaluation.
276#
277# This is necessary to resolve reference to local variables before doing
278# assignments and setting up commands. They would otherwise be resolved
279# later in a different context and the result would be completely wrong.
280#
281define def_unit_qt3_target_pre_handle_translation_dx
282
283$(out) + $(more_output) +| $(maybe_output): \
284 $(deps) \
285 $(value _UNIT_QT3_LRC_CMDS_DEP) \
286 | \
287 $(orderdeps)
288 %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
289 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
290
291$(cmds)
292
293ifndef NO_COMPILE_CMDS_DEPS
294 %$$(QUIET2)$$(APPEND) '$(dep)'
295 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_LRC_CMDS_PREV_'
296 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
297 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
298endif
299
300$(target)_OUT_FILES += $(out) $(more_output) $(maybe_output)
301$(target)-inst-nls_SOURCES += $(out)
302
303endef # def_unit_qt3_target_pre_handle_translation_dx
304
305##
306# Handle a source file listed in QT_TRANSLATIONS.
307#
308# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
309# to be translated into .qm files that are loadble by Qt.
310#
311# @remarks Invoked via $(evalvalctx ).
312define def_unit_qt3_target_pre_handle_translation
313local type := LRC
314
315# fetch the properties.
316local tool := $(kb-src-tool dummy_var)
317local qtnlsdir := $(PATH_$(target))/qtnls
318local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
319local out := $(outbase).qm
320local dep := $(out).dep
321local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
322local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
323local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
324
325# default path + source dep.
326ifneq ($(defpath),)
327local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
328local incs := $(abspathex $(incs),$($(target)_PATH))
329else
330local deps += $(source)
331endif
332
333# call the tool
334ifndef TOOL_$(tool)_LRC_TS_CMDS
335 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
336endif
337local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
338local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
339local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
340local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
341local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
342
343# generate the link rule and update some source and target variables.
344ifndef NO_COMPILE_CMDS_DEPS
345 $(eval includedep $(dep))
346endif
347$(eval $(def_unit_qt3_target_pre_handle_translation_dx))
348
349endef # def_unit_qt3_target_pre_handle_translation
350
351
352
353## wrapper for the UIC command dependencies.
354ifndef NO_COMPILE_CMDS_DEPS
355 _UNIT_QT3_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_UIC_CMDS_PREV_),$$(commands $(out.h)),FORCE)
356else
357 _UNIT_QT3_UIC_CMDS_DEP =
358endif
359
360##
361# def_unit_qt3_src_handler_ui helper that is expanded before evaluation.
362#
363# This is necessary to resolve reference to local variables before doing
364# assignments and setting up commands. They would otherwise be resolved
365# later in a different context and the result would be completely wrong.
366#
367define def_unit_qt3_target_pre_handle_ui_dx
368
369$(out.h) + $(out.cpp) +| $(realout.h) $(realout.cpp) $(more_output) $(maybe_output): \
370 $(deps) \
371 $(value _UNIT_QT3_UIC_CMDS_DEP) \
372 | \
373 $(orderdeps)
374 %$$(call MSG_TOOL,uic,$(target),$(source),$(out.h) $(out.cpp))
375 $(QUIET2)$(RM) -f $(out.h) $(out.cpp) $(more_output) $(maybe_output) $(dep)
376
377$(cmds)
378
379 $(QUIET)$(CP) --changed -f $(out.h) $(realout.h)
380 $(QUIET)$(CP) --changed -f $(out.cpp) $(realout.cpp)
381ifndef NO_COMPILE_CMDS_DEPS
382 %$$(QUIET2)$$(APPEND) '$(dep)'
383 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_UIC_CMDS_PREV_'
384 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out.h)'
385 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
386endif
387
388$(target)_INTERMEDIATES += $(realout.h)
389$(target)_GEN_SOURCES_ += $(realout.cpp)
390$(target)_OUT_FILES += $(out.h) $(out.cpp) $(realout.h) $(realout.cpp) $(more_output) $(maybe_output)
391
392endef # def_unit_qt3_target_pre_handle_ui_dx
393
394##
395# Source handler for .ui sources.
396#
397# @remarks $(evalvalctx me).
398define def_unit_qt3_src_handler_ui
399local type := UIC
400
401# fetch the properties.
402local tool := $(kb-src-tool dummy_var)
403local qtuicdir := $(PATH_$(target))/qtuic
404local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
405local out.h := $(outbase).tmp.h
406local out.cpp := $(outbase).tmp.cpp
407local realout.h := $(outbase).h
408local realout.cpp:=$(outbase).cpp
409local dep := $(realout.h).dep
410local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
411local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
412local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
413
414# default path + source dep.
415ifneq ($(defpath),)
416local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
417local incs := $(abspathex $(incs),$($(target)_PATH))
418else
419local deps += $(source)
420endif
421
422# call the tool
423ifndef TOOL_$(tool)_UIC_UI_CMDS
424 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
425endif
426local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
427local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
428local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
429local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
430local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
431
432# generate the link rule and update some source and target variables.
433ifndef NO_COMPILE_CMDS_DEPS
434 $(eval includedep $(dep))
435endif
436$(eval $(def_unit_qt3_target_pre_handle_ui_dx))
437
438endef # def_unit_qt3_src_handler_ui
439
440
441
442## wrapper for the MOC command dependencies.
443ifndef NO_COMPILE_CMDS_DEPS
444 _UNIT_QT3_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
445else
446 _UNIT_QT3_MOC_HPP_CMDS_DEP =
447endif
448
449##
450# def_unit_qt3_target_pre_handle_moc_hdr helper that is expanded before evaluation.
451#
452# This is necessary to resolve reference to local variables before doing
453# assignments and setting up commands. They would otherwise be resolved
454# later in a different context and the result would be completely wrong.
455#
456define def_unit_qt3_target_pre_handle_moc_hdr_dx
457
458$(out) +| $(realout) $(more_output) $(maybe_output): \
459 $(deps) \
460 $(value _UNIT_QT3_MOC_HPP_CMDS_DEP) \
461 | \
462 $(orderdeps)
463 %$$(call MSG_TOOL,moc,$(target),$(source),$(realout))
464 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
465
466$(cmds)
467
468 $(QUIET)$(CP) --changed -f $(out) $(realout)
469ifndef NO_COMPILE_CMDS_DEPS
470 %$$(QUIET2)$$(APPEND) '$(dep)'
471 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_MOC_HPP_CMDS_PREV_'
472 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
473 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
474endif
475
476$(target)_INTERMEDIATES += $(realout)
477$(target)_GEN_SOURCES_ += $(realout)
478$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
479
480endef
481
482##
483# Handle a source file listed in QT_MOCHDRS.
484#
485# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
486# generate a .cpp file for each of them and add it to the generated
487# sources so that it's compiled and linked. (There is an alternative
488# way to do this where the .cpp file is included, this isn't currently
489# supported by this unit.)
490#
491# @remarks Invoked via $(evalvalctx ).
492define def_unit_qt3_target_pre_handle_moc_hdr
493local type := MOC
494
495# fetch the properties.
496local tool := $(kb-src-tool dummy_var)
497local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
498local out := $(outbase).tmp.cpp
499local realout := $(outbase).cpp
500local dep := $(realout).dep
501local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
502local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
503local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
504
505# default path + source dep.
506ifneq ($(defpath),)
507local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
508else
509local deps += $(source)
510endif
511
512# call the tool
513ifndef TOOL_$(tool)_MOC_HPP_CMDS
514 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
515endif
516local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
517local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
518local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
519local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
520local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
521
522# generate the link rule and update some source and target variables.
523ifndef NO_COMPILE_CMDS_DEPS
524 $(eval includedep $(dep))
525endif
526$(eval $(def_unit_qt3_target_pre_handle_moc_hdr_dx))
527
528endef # def_unit_qt3_target_pre_handle_moc_hdr
529
530
531
532## wrapper for the MOC command dependencies.
533ifndef NO_COMPILE_CMDS_DEPS
534 _UNIT_QT3_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
535else
536 _UNIT_QT3_MOC_CPP_CMDS_DEP =
537endif
538
539##
540# def_unit_qt3_target_pre_handle_moc_src helper that is expanded before evaluation.
541#
542# This is necessary to resolve reference to local variables before doing
543# assignments and setting up commands. They would otherwise be resolved
544# later in a different context and the result would be completely wrong.
545#
546define def_unit_qt3_target_pre_handle_moc_src_dx
547
548$(out) +| $(realout) $(more_output) $(maybe_output): \
549 $(deps) \
550 $(value _UNIT_QT3_MOC_CPP_CMDS_DEP) \
551 | \
552 $(orderdeps)
553 %$$(call MSG_TOOL,moc,$(target),$(source),$(realout))
554 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
555
556$(cmds)
557
558 $(QUIET)$(CP) --changed -f $(out) $(realout)
559ifndef NO_COMPILE_CMDS_DEPS
560 %$$(QUIET2)$$(APPEND) '$(dep)'
561 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_MOC_CPP_CMDS_PREV_'
562 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
563 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
564endif
565
566$(target)_INTERMEDIATES += $(realout)
567$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
568
569endef
570
571##
572# Handle a source file listed in QT_MOCSRCS.
573#
574# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
575# a .moc file that we're expected to generate here.
576#
577# @remarks Invoked via $(evalvalctx ).
578define def_unit_qt3_target_pre_handle_moc_src
579local type := MOC
580
581# fetch the properties.
582local tool := $(kb-src-tool dummy_var)
583local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
584local out := $(outbase).tmp.moc
585local realout := $(outbase).moc
586local dep := $(realout).dep
587local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
588local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
589local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
590
591# default path + source dep.
592ifneq ($(defpath),)
593local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
594local incs := $(abspathex $(incs),$($(target)_PATH))
595else
596local deps += $(source)
597endif
598
599# call the tool
600ifndef TOOL_$(tool)_MOC_CPP_CMDS
601 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
602endif
603local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
604local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
605local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
606local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
607local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
608
609# generate the link rule and update some source and target variables.
610ifndef NO_COMPILE_CMDS_DEPS
611 $(eval includedep $(dep))
612endif
613$(eval $(def_unit_qt3_target_pre_handle_moc_src_dx))
614
615endef # def_unit_qt3_target_pre_handle_moc_src
616
617
618##
619# Adds sources containing Q_OBJECT to QT_MOCSRCS.
620define def_unit_qt3_target_pre_cpp_source
621ifneq ($(file-size $(source)),-1)
622 ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
623 $(eval $(target)_QT_MOCSRCS += $(source))
624 endif
625endif
626endef # def_unit_qt3_target_pre_cpp_source
627
628
629##
630# Invoked early in the processing of a target that uses the Qt unit.
631#
632# It will append the qt source handlers to the target (.h, .ui, .ts,
633# .png, .bmp, .gif).
634#
635# It will then check all the C++ sources and check which needs
636# a .moc files and generate rules and dependencies fofor these
637#
638define def_unit_qt3_target_pre
639
640# Make QTTOOL the default for the specific Qt tools instead of TOOL.
641ifneq ($($(target)_QTTOOL),)
642 ifeq ($($(target)_MOCTOOL),)
643 $(target)_MOCTOOL := $($(target)_QTTOOL)
644 endif
645 ifeq ($($(target)_UICTOOL),)
646 $(target)_UICTOOL := $($(target)_QTTOOL)
647 endif
648 ifeq ($($(target)_LRCTOOL),)
649 $(target)_LRCTOOL := $($(target)_QTTOOL)
650 endif
651endif
652
653# Deal with QT_MODULES and QT_PREFIX.
654local qt_prefix := $(firstword \
655 $($(target)_QT_PREFIX.$(_bld_trg)) \
656 $($(target)_QT_PREFIX.$(_bld_trg_arch)) \
657 $($(target)_QT_PREFIX.$(_bld_trg).$(_bld_trg_arch)) \
658 $($(target)_QT_PREFIX.$(_bld_trg_cpu)) \
659 $($(target)_QT_PREFIX.$(_bld_type)) \
660 $($(target)_QT_PREFIX))
661ifeq ($(bld_trg),win)
662 $(eval $(target)_LIBS += $(PATH_SDK_QT3_LIB)/$(qt_prefix)qt-mt$(SUFF_LIB)) )
663 ifeq ($(tool_do),LINK_PROGRAM)
664 $(eval $(target)_LIBS += $(PATH_SDK_QT3_LIB)/$(qt_prefix)qtmain$(SUFF_LIB) )
665 endif
666else
667 $(eval $(target)_LIBS += $(PATH_SDK_QT3_LIB)/lib$(qt_prefix)qt-mt$(SUFF_DLL) )
668endif
669$(eval $(target)_INCS += $(PATH_SDK_QT3_INC) )
670
671# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
672# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
673ifndef $(target)_QT_MOCSRCS
674 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
675 $($(target)_SOURCES.$(_bld_trg)) \
676 $($(target)_SOURCES.$(_bld_trg_arch)) \
677 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
678 $($(target)_SOURCES.$(_bld_trg_cpu)) \
679 $($(target)_SOURCES.$(_bld_type)) \
680 $($(target)_SOURCES) \
681 ), $(evalval def_unit_qt3_target_pre_cpp_source))
682endif
683
684# Install source handlers for .ui files.
685$(target)_SRC_HANDLERS += \
686 .ui:def_unit_qt3_src_handler_ui \
687 .UI:def_unit_qt3_src_handler_ui
688
689# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
690local qtmocdir := $(PATH_$(target))/qtmoc
691local qtuicdir := $(PATH_$(target))/qtuic
692local qtnlsdir := $(PATH_$(target))/qtnls
693$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtnlsdir) )
694$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir) )
695
696# Calc .ui sources so we can add them to the QT_MOCSRCS and QT_MOCHDRS.
697local ui_sources := $(notdir $(basename $(filter %.ui %.UI, \
698 $($(target)_SOURCES.$(_bld_trg)) \
699 $($(target)_SOURCES.$(_bld_trg_arch)) \
700 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
701 $($(target)_SOURCES.$(_bld_trg_cpu)) \
702 $($(target)_SOURCES.$(_bld_type)) \
703 $($(target)_SOURCES) \
704 )))
705#$(error ui_sources:=$(ui_sources))
706
707# Deal with QT_MOCSRCS.
708$(foreach source, \
709 $($(target)_QT_MOCSRCS.$(_bld_trg)) \
710 $($(target)_QT_MOCSRCS.$(_bld_trg_arch)) \
711 $($(target)_QT_MOCSRCS.$(_bld_trg).$(_bld_trg_arch)) \
712 $($(target)_QT_MOCSRCS.$(_bld_trg_cpu)) \
713 $($(target)_QT_MOCSRCS.$(_bld_type)) \
714 $($(target)_QT_MOCSRCS) \
715 $(addsuffix .h,$(addprefix $(qtuicdir)/,$(notdir $(basename $(ui_sources))))) \
716 , $(evalvalctx def_unit_qt3_target_pre_handle_moc_src))
717
718# Deal with QT_MOCHDRS.
719$(foreach source, \
720 $($(target)_QT_MOCHDRS.$(_bld_trg)) \
721 $($(target)_QT_MOCHDRS.$(_bld_trg_arch)) \
722 $($(target)_QT_MOCHDRS.$(_bld_trg).$(_bld_trg_arch)) \
723 $($(target)_QT_MOCHDRS.$(_bld_trg_cpu)) \
724 $($(target)_QT_MOCHDRS.$(_bld_type)) \
725 $($(target)_QT_MOCHDRS) \
726 $(addsuffix .h,$(addprefix $(qtuicdir)/,$(notdir $(basename $(ui_sources))))) \
727 , $(evalvalctx def_unit_qt3_target_pre_handle_moc_hdr))
728
729# Deal with QT_TRANSLATIONS.
730# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
731local translations := \
732 $($(target)_QT_TRANSLATIONS.$(_bld_trg)) \
733 $($(target)_QT_TRANSLATIONS.$(_bld_trg_arch)) \
734 $($(target)_QT_TRANSLATIONS.$(_bld_trg).$(_bld_trg_arch)) \
735 $($(target)_QT_TRANSLATIONS.$(_bld_trg_cpu)) \
736 $($(target)_QT_TRANSLATIONS.$(_bld_type)) \
737 $($(target)_QT_TRANSLATIONS)
738ifneq ($(strip $(translations)),)
739 local expr := _ALL_INSTALLS += $(target)-inst-nls
740 $(eval $(expr))
741 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
742 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
743 else
744 $(target)-inst-nls_MODE := 0644
745 endif
746 ifdef $(target)_QT_TRANSLATIONS_INST
747 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
748 endif
749 $(target)-inst-nls_SOURCES :=
750 $(foreach source, $(translations)\
751 , $(evalvalctx def_unit_qt3_target_pre_handle_translation))
752endif
753
754endef # def_unit_qt3_target_pre
755
Note: See TracBrowser for help on using the repository browser.