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

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

qt3: Load the .prl file for the library.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 31.0 KB
Line 
1# $Id: qt3.kmk 1770 2008-09-08 00:27:28Z bird $
2## @file
3# Qt 3.3.x 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
53# PATH_SDK_QT3 - the general location of the Qt3 SDK stuff.
54# PATH_SDK_QT3_INC - the Qt3 include directory.
55# PATH_SDK_QT3_LIB - the Qt3 library directory for KBUILD_TARGET.
56# PATH_SDK_QT3_LIB.amd64 - the Qt3 library directory for AMD64.
57# PATH_SDK_QT3_LIB.x86 - the Qt3 library directory for X86.
58ifndef PATH_SDK_QT3
59 PATH_SDK_QT3 := $(firstword $(rsort $(wildcard $(PATH_DEVTOOLS_TRG)/qt/v3*)))
60 ifeq ($(PATH_SDK_QT3),)
61 # If target == host, try look for Qt in the various platform specific places.
62 ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
63 ifeq ($(KBUILD_TARGET),darwin)
64 # No idea here yet...
65 else ifeq ($(KBUILD_TARGET),os2)
66 # No idea here yet...
67 else ifeq ($(KBUILD_TARGET),win)
68 # No idea here yet...
69 else
70 # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT3_LIB* stuff if it doesn't work.
71 # Try find the general location of the thing by looking for the qm2ts program, then try looking for
72 # the moc program in likely and unlikely places save /usr[/local]/bin to avoid mistaking it with Qt4.
73 PATH_SDK_QT3 := $(patsubst %/bin/qm2ts,%,$(firstword $(wildcard \
74 /usr/lib/qt-3.3/bin/qm2ts \
75 /usr/lib64/qt-3.3/bin/qm2ts \
76 /usr/qt/3/bin/qm2ts \
77 $(if $(QTDIR),$(QTDIR)/bin/qm2ts) \
78 /usr/bin/qm2ts \
79 /usr/local/bin/qm2ts \
80 /usr/share/qt3/bin/qm2ts \
81 )))
82 ifeq ($(PATH_SDK_QT3),) # Try with moc, but not in /usr/bin and /usr/local/bin.
83 PATH_SDK_QT3 := $(patsubst %/bin/moc,%,$(firstword $(wildcard \
84 /usr/lib/qt-3.3/bin/moc \
85 /usr/lib64/qt-3.3/bin/moc \
86 /usr/qt/3/bin/moc \
87 /usr/share/qt3/bin/moc \
88 $(if $(QTDIR),$(QTDIR)/bin/moc) \
89 )))
90 endif
91 ifneq ($(PATH_SDK_QT3),)
92 # Found something! Export the variable for the benefit of recursive make instances.
93 export PATH_SDK_QT3
94
95 # Determin the include directory.
96 ifeq ($(PATH_SDK_QT3_INC),)
97 PATH_SDK_QT3_INC := $(patsubst %/private/qfiledefs_p.h,%,$(firstword $(wildcard \
98 $(PATH_SDK_QT3)/include/private/qfiledefs_p.h \
99 $(PATH_SDK_QT3)/include/qt3/private/qfiledefs_p.h \
100 /usr/include/qt3/private/qfiledefs_p.h)))
101 ifneq ($(PATH_SDK_QT3_INC),)
102 export PATH_SDK_QT3_INC
103 endif
104 endif
105
106 # Determin the most likely x86 and AMD64 lib directories (only used for making PATH_SDK_QT3_LIB).
107 ifeq ($(PATH_SDK_QT3_LIB.x86),)
108 PATH_SDK_QT3_LIB.x86 := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
109 $(PATH_SDK_QT3)/lib32/libqt-mt$(SUFF_DLL) \
110 $(PATH_SDK_QT3)/lib32/qt3/libqt-mt$(SUFF_DLL) \
111 $(PATH_SDK_QT3)/lib32/qt3-3/lib/libqt-mt$(SUFF_DLL) \
112 /usr/lib32/libqt-mt$(SUFF_DLL) \
113 /usr/lib32/qt3/libqt-mt$(SUFF_DLL) \
114 /usr/lib32/qt3-3/lib/libqt-mt$(SUFF_DLL) \
115 /usr/local/lib32/libqt-mt$(SUFF_DLL) \
116 /usr/local/lib32/qt3/libqt-mt$(SUFF_DLL) \
117 /usr/local/lib32/qt3-3/lib/libqt-mt$(SUFF_DLL) \
118 $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
119 $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
120 $(PATH_SDK_QT3)/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
121 )))
122 ifneq ($(PATH_SDK_QT3_LIB.x86),)
123 export PATH_SDK_QT3_LIB.x86
124 endif
125 endif
126 ifeq ($(PATH_SDK_QT3_LIB.amd64),)
127 PATH_SDK_QT3_LIB.amd64 := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
128 $(PATH_SDK_QT3)/lib64/libqt-mt$(SUFF_DLL) \
129 $(PATH_SDK_QT3)/lib64/qt3/libqt-mt$(SUFF_DLL) \
130 $(PATH_SDK_QT3)/lib64/qt3-3/lib/libqt-mt$(SUFF_DLL) \
131 $(PATH_SDK_QT3)/lib/amd64/libqt-mt$(SUFF_DLL) \
132 $(PATH_SDK_QT3)/lib/64/libqt-mt$(SUFF_DLL) \
133 /usr/lib64/libqt-mt$(SUFF_DLL) \
134 /usr/lib64/qt3/libqt-mt$(SUFF_DLL) \
135 /usr/lib64/qt3-3/lib/libqt-mt$(SUFF_DLL) \
136 /usr/lib/amd64/libqt-mt$(SUFF_DLL) \
137 /usr/lib/64/libqt-mt$(SUFF_DLL) \
138 /usr/local/lib64/libqt-mt$(SUFF_DLL) \
139 /usr/local/lib64/qt3/libqt-mt$(SUFF_DLL) \
140 /usr/local/lib64/qt3-3/lib/libqt-mt$(SUFF_DLL) \
141 /usr/local/lib/amd64/libqt-mt$(SUFF_DLL) \
142 /usr/local/lib/64/libqt-mt$(SUFF_DLL) \
143 $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
144 $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
145 $(PATH_SDK_QT3)/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
146 )))
147 ifneq ($(PATH_SDK_QT3_LIB.amd64),)
148 export PATH_SDK_QT3_LIB.amd64
149 endif
150 endif
151
152 # Determin the KBUILD_TARGET lib directory.
153 ifeq ($(PATH_SDK_QT3_LIB),)
154 PATH_SDK_QT3_LIB := $(PATH_SDK_QT3_LIB.$(KBUILD_TARGET))
155 ifeq ($(PATH_SDK_QT3_LIB),)
156 PATH_SDK_QT3_LIB := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
157 $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
158 $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
159 $(PATH_SDK_QT3)/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
160 /usr/lib/libqt-mt$(SUFF_DLL) \
161 /usr/lib/qt3/libqt-mt$(SUFF_DLL) \
162 /usr/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
163 /usr/local/lib/libqt-mt$(SUFF_DLL) \
164 /usr/local/lib/qt3/libqt-mt$(SUFF_DLL) \
165 /usr/local/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
166 )))
167 ifneq ($(PATH_SDK_QT3_LIB),)
168 export PATH_SDK_QT3_LIB
169 endif
170 endif
171 endif
172
173 endif
174 endif # Unices
175 endif
176 # Found it?
177 ifeq ($(PATH_SDK_QT3),)
178 $(warning kBuild: Couldn't find the Qt3 headers and libaries...)
179 PATH_SDK_QT3 := $(PATH_DEVTOOLS_TRG)/qt/not-found
180 endif
181 endif
182else
183 # Resolve any fancy stuff once and for all.
184 PATH_SDK_QT3 := $(PATH_SDK_QT3)
185endif
186
187# Libraries can be in either Frameworks or lib depending on how you
188# build it on the mac. The .dmg installs into Frameworks but builds into lib.
189PATH_SDK_QT3_LIB ?= $(PATH_SDK_QT3)/lib
190PATH_SDK_QT3_INC ?= $(PATH_SDK_QT3)/include
191
192# The bits that kBuild picks up.
193# (nothing here)
194
195
196#
197# The QT3 tool.
198#
199# This is implemented here rather than in tools/QT3.kmk to enforce the global USES.
200# It also makes things easier to develop, with fewer files I mean.
201#
202TOOL_QT3 = Qt3
203
204# Tool Specific Properties (PATH_TOOL_QT3_BIN and TOOL_QT3_BIN_SUFF)
205# TOOL_QT3_BIN_SUFF - the '-qt3' bit found on debian.
206# PATH_TOOL_QT3_BIN - the directory containing moc, uic, lrelease, lupdate and qm2ts.
207ifndef PATH_TOOL_QT3_BIN
208 PATH_TOOL_QT3_BIN := $(firstword $(rsort $(wildcard $(PATH_DEVTOOLS_BLD)/qt/v3*/bin)))
209 ifeq ($(PATH_TOOL_QT3_BIN),)
210 if1of ($(KBUILD_HOST), win os2)
211 # sorry, no joy here.
212 else
213 ifdef TOOL_QT3_BIN_SUFF
214 TOOL_QT3_BIN_SUFF := $(TOOL_QT3_BIN_SUFF)
215 endif
216 PATH_TOOL_QT3_BIN := $(patsubst %/qm2ts$(TOOL_QT3_BIN_SUFF),%,$(firstword $(wildcard \
217 /usr/lib/qt-3.3/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
218 /usr/lib64/qt-3.3/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
219 /usr/qt/3/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
220 $(if $(QTDIR),$(QTDIR)/bin/qm2ts$(TOOL_QT3_BIN_SUFF)) \
221 /usr/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
222 /usr/local/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
223 /usr/share/qt3/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
224 )))
225 ifeq ($(PATH_TOOL_QT3_BIN),)
226 # If we couldn't find the qt3 specific tool qm2ts, debian and other skip
227 # this (thanks a bundle). Try with look for 'moc' with a '-qt3' extension,
228 # then for just moc. In the latter case don't search /usr[/local]/bin to
229 # void finding the qt4 tools and messing up.
230 ifeq ($(TOOL_QT3_BIN_SUFF),)
231 PATH_TOOL_QT3_BIN := $(patsubst %/moc-qt3,%,$(firstword $(wildcard \
232 /usr/bin/moc-qt3 \
233 /usr/local/bin/moc-qt3 \
234 /usr/lib/qt-3.3/bin/moc-qt3 \
235 /usr/lib64/qt-3.3/bin/moc-qt3 \
236 /usr/qt/3/bin/moc-qt3 \
237 /usr/share/qt3/bin/moc-qt3 \
238 $(if $(QTDIR),$(QTDIR)/bin/moc-qt3) \
239 )))
240 endif
241 ifneq ($(PATH_TOOL_QT3_BIN),)
242 export TOOL_QT3_BIN_SUFF := -qt3
243 else
244 PATH_TOOL_QT3_BIN := $(patsubst %/moc$(TOOL_QT3_BIN_SUFF),%,$(firstword $(wildcard \
245 /usr/lib/qt-3.3/bin/moc$(TOOL_QT3_BIN_SUFF) \
246 /usr/lib64/qt-3.3/bin/moc$(TOOL_QT3_BIN_SUFF) \
247 /usr/qt/3/bin/moc$(TOOL_QT3_BIN_SUFF) \
248 /usr/share/qt3/bin/moc$(TOOL_QT3_BIN_SUFF) \
249 $(if $(QTDIR),$(QTDIR)/bin/moc$(TOOL_QT3_BIN_SUFF)) \
250 )))
251 endif
252 endif
253 ifneq ($(PATH_TOOL_QT3_BIN),)
254 export PATH_TOOL_QT3_BIN
255 endif
256 endif
257 endif
258 # If not found, we'll enter the 'pathless' mode.
259else
260 # Resolve any fancy stuff once and for all.
261 PATH_TOOL_QT3_BIN := $(PATH_TOOL_QT3_BIN)
262 TOOL_QT3_BIN_SUFF := $(TOOL_QT3_BIN_SUFF)
263endif
264ifneq ($(PATH_TOOL_QT3_BIN),)
265 TOOL_QT3_MOC ?= $(PATH_TOOL_QT3_BIN)/moc$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
266 TOOL_QT3_UIC ?= $(PATH_TOOL_QT3_BIN)/uic$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
267 TOOL_QT3_LRC ?= $(PATH_TOOL_QT3_BIN)/lrelease$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
268 TOOL_QT3_LUPDATE ?= $(PATH_TOOL_QT3_BIN)/lupdate$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
269else
270 # Pathless, relies on the environment.
271 TOOL_QT3_MOC ?= moc$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
272 TOOL_QT3_UIC ?= uic$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
273 TOOL_QT3_LRC ?= lrelease$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
274 TOOL_QT3_LUPDATE ?= lupdate$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
275endif
276
277# General Properties used by kBuild and/or units/qt.kmk
278TOOL_QT3_MOCFLAGS ?=
279TOOL_QT3_UICFLAGS ?=
280TOOL_QT3_LRCFLAGS ?=
281
282
283## MOC a C++ source file.
284# @param $(target) Normalized main target name.
285# @param $(source) Source filename (relative).
286# @param $(out) Object file name. This shall be (re)created by the compilation.
287# @param $(dep) Dependcy file. This may be (re)created by the compilation.
288# @param $(flags) Flags.
289# @param $(outbase) Output basename (full). Use this for list files and such.
290#
291TOOL_QT3_MOC_CPP_DEPEND =
292TOOL_QT3_MOC_CPP_DEPORD =
293TOOL_QT3_MOC_CPP_OUTPUT =
294TOOL_QT3_MOC_CPP_OUTPUT_MAYBE =
295define TOOL_QT3_MOC_CPP_CMDS
296 $(QUIET)$(TOOL_QT3_MOC)\
297 $(flags)\
298 -o $(out)\
299 -i \
300 $(source)
301endef
302
303## MOC a C++ header file.
304# @param $(target) Normalized main target name.
305# @param $(source) Source filename (relative).
306# @param $(out) Object file name. This shall be (re)created by the compilation.
307# @param $(dep) Dependcy file. This may be (re)created by the compilation.
308# @param $(flags) Flags.
309# @param $(outbase) Output basename (full). Use this for list files and such.
310#
311TOOL_QT3_MOC_HPP_DEPEND =
312TOOL_QT3_MOC_HPP_DEPORD =
313TOOL_QT3_MOC_HPP_OUTPUT =
314TOOL_QT3_MOC_HPP_OUTPUT_MAYBE =
315define TOOL_QT3_MOC_HPP_CMDS
316 $(QUIET)$(TOOL_QT3_MOC)\
317 $(flags)\
318 -o $(out)\
319 $(source)
320endef
321
322## Compile a Qt user interface file (.ui).
323# @param $(target) Normalized main target name.
324# @param $(source) Source filename (relative).
325# @param $(out.cpp) The C++ source file to be generated.
326# @param $(out.h) The C++ header file to be generated.
327# @param $(dep) Dependcy file. This may be (re)created by the compilation.
328# @param $(flags) Flags.
329# @param $(outbase) Output basename (full). Use this for list files and such.
330#
331TOOL_QT3_UIC_UI_DEPEND =
332TOOL_QT3_UIC_UI_DEPORD =
333TOOL_QT3_UIC_UI_OUTPUT =
334TOOL_QT3_UIC_UI_OUTPUT_MAYBE =
335define TOOL_QT3_UIC_UI_CMDS
336 $(QUIET)$(TOOL_QT3_UIC)\
337 $(flags)\
338 -o $(out.h)\
339 $(source)
340 $(QUIET)$(TOOL_QT3_UIC)\
341 $(flags)\
342 -i $(out.h) \
343 -o $(out.cpp)\
344 $(source)
345endef
346
347## Compile a Qt translation file (.ts).
348# @param $(target) Normalized main target name.
349# @param $(source) Source filename (relative).
350# @param $(out) Object file name. This shall be (re)created by the compilation.
351# @param $(dep) Dependcy file. This may be (re)created by the compilation.
352# @param $(flags) Flags.
353# @param $(defs) Definitions.
354# @param $(incs) Includes.
355# @param $(outbase) Output basename (full). Use this for list files and such.
356#
357TOOL_QT3_LRC_TS_DEPEND =
358TOOL_QT3_LRC_TS_DEPORD =
359TOOL_QT3_LRC_TS_OUTPUT =
360TOOL_QT3_LRC_TS_OUTPUT_MAYBE =
361define TOOL_QT3_LRC_TS_CMDS
362 $(QUIET)$(TOOL_QT3_LRC)\
363 $(flags)\
364 $(source)\
365 -qm $(out)
366endef
367
368
369
370#
371#
372# Back to the Qt3 unit.
373#
374#
375
376
377## wrapper for the lrelease (LRC) command dependencies.
378ifndef NO_COMPILE_CMDS_DEPS
379 _UNIT_QT3_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
380else
381 _UNIT_QT3_LRC_CMDS_DEP =
382endif
383
384##
385# def_unit_qt3_target_pre_handle_translation helper that is expanded before evaluation.
386#
387# This is necessary to resolve reference to local variables before doing
388# assignments and setting up commands. They would otherwise be resolved
389# later in a different context and the result would be completely wrong.
390#
391define def_unit_qt3_target_pre_handle_translation_dx
392
393$(out) + $(more_output) +| $(maybe_output): \
394 $(deps) \
395 $(value _UNIT_QT3_LRC_CMDS_DEP) \
396 | \
397 $(orderdeps)
398 %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
399 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
400
401$(cmds)
402
403ifndef NO_COMPILE_CMDS_DEPS
404 %$$(QUIET2)$$(APPEND) '$(dep)'
405 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_LRC_CMDS_PREV_'
406 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
407 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
408endif
409
410$(target)_OUT_FILES += $(out) $(more_output) $(maybe_output)
411$(target)-inst-nls_SOURCES += $(out)
412
413endef # def_unit_qt3_target_pre_handle_translation_dx
414
415##
416# Handle a source file listed in QT_TRANSLATIONS.
417#
418# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
419# to be translated into .qm files that are loadble by Qt.
420#
421# @remarks Invoked via $(evalvalctx ).
422define def_unit_qt3_target_pre_handle_translation
423local type := LRC
424
425# fetch the properties.
426local tool := $(kb-src-tool dummy_var)
427local qtnlsdir := $(PATH_$(target))/qtnls
428local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
429local out := $(outbase).qm
430local dep := $(out).dep
431local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
432local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
433local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
434
435# default path + source dep.
436ifneq ($(defpath),)
437local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
438local incs := $(abspathex $(incs),$($(target)_PATH))
439else
440local deps += $(source)
441endif
442
443# call the tool
444ifndef TOOL_$(tool)_LRC_TS_CMDS
445 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
446endif
447local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
448local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
449local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
450local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
451local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
452
453# generate the link rule and update some source and target variables.
454ifndef NO_COMPILE_CMDS_DEPS
455 $(eval includedep $(dep))
456endif
457$(eval $(def_unit_qt3_target_pre_handle_translation_dx))
458
459endef # def_unit_qt3_target_pre_handle_translation
460
461
462
463## wrapper for the UIC command dependencies.
464ifndef NO_COMPILE_CMDS_DEPS
465 _UNIT_QT3_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_UIC_CMDS_PREV_),$$(commands $(out.h)),FORCE)
466else
467 _UNIT_QT3_UIC_CMDS_DEP =
468endif
469
470##
471# def_unit_qt3_src_handler_ui helper that is expanded before evaluation.
472#
473# This is necessary to resolve reference to local variables before doing
474# assignments and setting up commands. They would otherwise be resolved
475# later in a different context and the result would be completely wrong.
476#
477define def_unit_qt3_target_pre_handle_ui_dx
478
479$(out.h) + $(out.cpp) +| $(realout.h) $(realout.cpp) $(more_output) $(maybe_output): \
480 $(deps) \
481 $(value _UNIT_QT3_UIC_CMDS_DEP) \
482 | \
483 $(orderdeps)
484 %$$(call MSG_TOOL,uic,$(target),$(source),$(out.h) $(out.cpp))
485 $(QUIET2)$(RM) -f $(out.h) $(out.cpp) $(more_output) $(maybe_output) $(dep)
486
487$(cmds)
488
489 $(QUIET)$(CP) --changed -f $(out.h) $(realout.h)
490 $(QUIET)$(CP) --changed -f $(out.cpp) $(realout.cpp)
491ifndef NO_COMPILE_CMDS_DEPS
492 %$$(QUIET2)$$(APPEND) '$(dep)'
493 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_UIC_CMDS_PREV_'
494 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out.h)'
495 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
496endif
497
498$(target)_INTERMEDIATES += $(realout.h)
499$(target)_GEN_SOURCES_ += $(realout.cpp)
500$(target)_OUT_FILES += $(out.h) $(out.cpp) $(realout.h) $(realout.cpp) $(more_output) $(maybe_output)
501
502endef # def_unit_qt3_target_pre_handle_ui_dx
503
504##
505# Source handler for .ui sources.
506#
507# @remarks $(evalvalctx me).
508define def_unit_qt3_src_handler_ui
509local type := UIC
510
511# fetch the properties.
512local tool := $(kb-src-tool dummy_var)
513local qtuicdir := $(PATH_$(target))/qtuic
514local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
515local out.h := $(outbase).tmp.h
516local out.cpp := $(outbase).tmp.cpp
517local realout.h := $(outbase).h
518local realout.cpp:=$(outbase).cpp
519local dep := $(realout.h).dep
520local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
521local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
522local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
523
524# default path + source dep.
525ifneq ($(defpath),)
526local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
527local incs := $(abspathex $(incs),$($(target)_PATH))
528else
529local deps += $(source)
530endif
531
532# call the tool
533ifndef TOOL_$(tool)_UIC_UI_CMDS
534 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
535endif
536local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
537local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
538local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
539local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
540local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
541
542# generate the link rule and update some source and target variables.
543ifndef NO_COMPILE_CMDS_DEPS
544 $(eval includedep $(dep))
545endif
546$(eval $(def_unit_qt3_target_pre_handle_ui_dx))
547
548endef # def_unit_qt3_src_handler_ui
549
550
551
552## wrapper for the MOC command dependencies.
553ifndef NO_COMPILE_CMDS_DEPS
554 _UNIT_QT3_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
555else
556 _UNIT_QT3_MOC_HPP_CMDS_DEP =
557endif
558
559##
560# def_unit_qt3_target_pre_handle_moc_hdr helper that is expanded before evaluation.
561#
562# This is necessary to resolve reference to local variables before doing
563# assignments and setting up commands. They would otherwise be resolved
564# later in a different context and the result would be completely wrong.
565#
566define def_unit_qt3_target_pre_handle_moc_hdr_dx
567
568$(out) +| $(realout) $(more_output) $(maybe_output): \
569 $(deps) \
570 $(value _UNIT_QT3_MOC_HPP_CMDS_DEP) \
571 | \
572 $(orderdeps)
573 %$$(call MSG_TOOL,moc,$(target),$(source),$(realout))
574 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
575
576$(cmds)
577
578 $(QUIET)$(CP) --changed -f $(out) $(realout)
579ifndef NO_COMPILE_CMDS_DEPS
580 %$$(QUIET2)$$(APPEND) '$(dep)'
581 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_MOC_HPP_CMDS_PREV_'
582 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
583 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
584endif
585
586$(target)_INTERMEDIATES += $(realout)
587$(target)_GEN_SOURCES_ += $(realout)
588$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
589
590endef
591
592##
593# Handle a source file listed in QT_MOCHDRS.
594#
595# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
596# generate a .cpp file for each of them and add it to the generated
597# sources so that it's compiled and linked. (There is an alternative
598# way to do this where the .cpp file is included, this isn't currently
599# supported by this unit.)
600#
601# @remarks Invoked via $(evalvalctx ).
602define def_unit_qt3_target_pre_handle_moc_hdr
603local type := MOC
604
605# fetch the properties.
606local tool := $(kb-src-tool dummy_var)
607local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
608local out := $(outbase).tmp.cpp
609local realout := $(outbase).cpp
610local dep := $(realout).dep
611local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
612local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
613local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
614
615# default path + source dep.
616ifneq ($(defpath),)
617local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
618else
619local deps += $(source)
620endif
621
622# call the tool
623ifndef TOOL_$(tool)_MOC_HPP_CMDS
624 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
625endif
626local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
627local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
628local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
629local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
630local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
631
632# generate the link rule and update some source and target variables.
633ifndef NO_COMPILE_CMDS_DEPS
634 $(eval includedep $(dep))
635endif
636$(eval $(def_unit_qt3_target_pre_handle_moc_hdr_dx))
637
638endef # def_unit_qt3_target_pre_handle_moc_hdr
639
640
641
642## wrapper for the MOC command dependencies.
643ifndef NO_COMPILE_CMDS_DEPS
644 _UNIT_QT3_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
645else
646 _UNIT_QT3_MOC_CPP_CMDS_DEP =
647endif
648
649##
650# def_unit_qt3_target_pre_handle_moc_src helper that is expanded before evaluation.
651#
652# This is necessary to resolve reference to local variables before doing
653# assignments and setting up commands. They would otherwise be resolved
654# later in a different context and the result would be completely wrong.
655#
656define def_unit_qt3_target_pre_handle_moc_src_dx
657
658$(out) +| $(realout) $(more_output) $(maybe_output): \
659 $(deps) \
660 $(value _UNIT_QT3_MOC_CPP_CMDS_DEP) \
661 | \
662 $(orderdeps)
663 %$$(call MSG_TOOL,moc,$(target),$(source),$(realout))
664 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
665
666$(cmds)
667
668 $(QUIET)$(CP) --changed -f $(out) $(realout)
669ifndef NO_COMPILE_CMDS_DEPS
670 %$$(QUIET2)$$(APPEND) '$(dep)'
671 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_MOC_CPP_CMDS_PREV_'
672 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
673 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
674endif
675
676$(target)_INTERMEDIATES += $(realout)
677$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
678
679endef
680
681##
682# Handle a source file listed in QT_MOCSRCS.
683#
684# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
685# a .moc file that we're expected to generate here.
686#
687# @remarks Invoked via $(evalvalctx ).
688define def_unit_qt3_target_pre_handle_moc_src
689local type := MOC
690
691# fetch the properties.
692local tool := $(kb-src-tool dummy_var)
693local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
694local out := $(outbase).tmp.moc
695local realout := $(outbase).moc
696local dep := $(realout).dep
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_qt3_target_pre_handle_moc_src_dx))
724
725endef # def_unit_qt3_target_pre_handle_moc_src
726
727
728##
729# Adds sources containing Q_OBJECT to QT_MOCSRCS.
730define def_unit_qt3_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_qt3_target_pre_cpp_source
737
738
739##
740# Invoked early in the processing of a target that uses the Qt unit.
741#
742# It will append the qt source handlers to the target (.h, .ui, .ts,
743# .png, .bmp, .gif).
744#
745# It will then check all the C++ sources and check which needs
746# a .moc files and generate rules and dependencies fofor these
747#
748define def_unit_qt3_target_pre
749
750# Make QTTOOL the default for the specific Qt tools instead of TOOL.
751ifneq ($($(target)_QTTOOL),)
752 ifeq ($($(target)_MOCTOOL),)
753 $(target)_MOCTOOL := $($(target)_QTTOOL)
754 endif
755 ifeq ($($(target)_UICTOOL),)
756 $(target)_UICTOOL := $($(target)_QTTOOL)
757 endif
758 ifeq ($($(target)_LRCTOOL),)
759 $(target)_LRCTOOL := $($(target)_QTTOOL)
760 endif
761endif
762
763# Deal with QT_MODULES and QT_PREFIX.
764local qt_prefix := $(firstword \
765 $($(target)_QT_PREFIX.$(bld_trg)) \
766 $($(target)_QT_PREFIX.$(bld_trg_arch)) \
767 $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
768 $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
769 $($(target)_QT_PREFIX.$(bld_type)) \
770 $($(target)_QT_PREFIX))
771ifeq ($(bld_trg),win)
772 local qt_lib := $(firstword $(wildcard \
773 $(PATH_SDK_QT3_LIB)/dynamic/$(qt_prefix)qt-mt3*$(SUFF_LIB) \
774 $(PATH_SDK_QT3_LIB)/$(qt_prefix)qt-mt3*$(SUFF_LIB) \
775 $(PATH_SDK_QT3_LIB)/dynamic/$(qt_prefix)qt-mt$(SUFF_LIB) \
776 $(PATH_SDK_QT3_LIB)/$(qt_prefix)qt-mt$(SUFF_LIB) \
777 $(PATH_SDK_QT3_LIB)/dynamic/$(qt_prefix)Qt3*$(SUFF_LIB) \
778 $(PATH_SDK_QT3_LIB)/$(qt_prefix)Qt3*$(SUFF_LIB) \
779 $(PATH_SDK_QT3_LIB)/dynamic/$(qt_prefix)Qt*$(SUFF_LIB) \
780 $(PATH_SDK_QT3_LIB)/$(qt_prefix)Qt*$(SUFF_LIB) \
781 ) $(PATH_SDK_QT3_LIB)/$(qt_prefix)qt-mt$(SUFF_LIB) )
782 $(eval $(target)_LIBS += $(qt_lib) )
783 ifeq ($(tool_do),LINK_PROGRAM)
784 local qt_main_lib := $(firstword $(wildcard \
785 $(PATH_SDK_QT3_LIB)/$(qt_prefix)qtmain$(SUFF_LIB) \
786 $(PATH_SDK_QT3_LIB)/qtmain$(SUFF_LIB) \
787 ) $(PATH_SDK_QT3_LIB)/$(qt_prefix)qtmain$(SUFF_LIB) )
788 $(eval $(target)_LIBS += $(qt_main_lib) )
789 endif
790else
791 local qt_lib := $(PATH_SDK_QT3_LIB)/lib$(qt_prefix)qt-mt$(SUFF_DLL)
792 $(eval $(target)_LIBS += $(qt_lib) )
793endif
794$(eval $(target)_INCS += $(PATH_SDK_QT3_INC) )
795
796# On Qt3 we will try pickup the QMAKE_PRL_DEFINES listed in the .prl file (in libs).
797local qt_prl := $(firstword $(wildcard \
798 $(patsubst %$(SUFF_DLL),%,$(patsubst %$(SUFF_LIB),%,$(qt_lib))).prl \
799 $(dir $(qt_lib))/$(qt_prefix)qt-mt.prl \
800 $(dir $(qt_lib))/*qt-mt*.prl \
801 $(dir $(qt_lib))/*qt*.prl \
802 ))
803ifneq ($(qt_prl),)
804 include $(qt_prl)
805 $(eval $(target)_DEFS += $(QMAKE_PRL_DEFINES))
806endif
807
808# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
809# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
810ifndef $(target)_QT_MOCSRCS
811 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
812 $($(target)_SOURCES.$(bld_trg)) \
813 $($(target)_SOURCES.$(bld_trg_arch)) \
814 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
815 $($(target)_SOURCES.$(bld_trg_cpu)) \
816 $($(target)_SOURCES.$(bld_type)) \
817 $($(target)_SOURCES) \
818 ), $(evalval def_unit_qt3_target_pre_cpp_source))
819endif
820
821# Install source handlers for .ui files.
822$(target)_SRC_HANDLERS += \
823 .ui:def_unit_qt3_src_handler_ui \
824 .UI:def_unit_qt3_src_handler_ui
825
826# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
827local qtmocdir := $(PATH_$(target))/qtmoc
828local qtuicdir := $(PATH_$(target))/qtuic
829local qtnlsdir := $(PATH_$(target))/qtnls
830$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtnlsdir) )
831$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir) )
832
833# Calc .ui sources so we can add them to the QT_MOCSRCS and QT_MOCHDRS.
834local ui_sources := $(notdir $(basename $(filter %.ui %.UI, \
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 )))
842#$(error ui_sources:=$(ui_sources))
843
844# Deal with QT_MOCSRCS.
845$(foreach source, \
846 $($(target)_QT_MOCSRCS.$(bld_trg)) \
847 $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
848 $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
849 $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
850 $($(target)_QT_MOCSRCS.$(bld_type)) \
851 $($(target)_QT_MOCSRCS) \
852 $(addsuffix .h,$(addprefix $(qtuicdir)/,$(notdir $(basename $(ui_sources))))) \
853 , $(evalvalctx def_unit_qt3_target_pre_handle_moc_src))
854
855# Deal with QT_MOCHDRS.
856$(foreach source, \
857 $($(target)_QT_MOCHDRS.$(bld_trg)) \
858 $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
859 $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
860 $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
861 $($(target)_QT_MOCHDRS.$(bld_type)) \
862 $($(target)_QT_MOCHDRS) \
863 $(addsuffix .h,$(addprefix $(qtuicdir)/,$(notdir $(basename $(ui_sources))))) \
864 , $(evalvalctx def_unit_qt3_target_pre_handle_moc_hdr))
865
866# Deal with QT_TRANSLATIONS.
867# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
868local translations := \
869 $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
870 $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
871 $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
872 $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
873 $($(target)_QT_TRANSLATIONS.$(bld_type)) \
874 $($(target)_QT_TRANSLATIONS)
875ifneq ($(strip $(translations)),)
876 local expr := _ALL_INSTALLS += $(target)-inst-nls
877 $(eval $(expr))
878 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
879 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
880 else
881 $(target)-inst-nls_MODE := 0644
882 endif
883 ifdef $(target)_QT_TRANSLATIONS_INST
884 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
885 endif
886 $(target)-inst-nls_SOURCES :=
887 $(foreach source, $(translations)\
888 , $(evalvalctx def_unit_qt3_target_pre_handle_translation))
889endif
890
891endef # def_unit_qt3_target_pre
892
893
894#
895# Rule for debugging.
896#
897unit-qt3-show-vars:
898 @$(ECHO) 'The Qt3 SDK variables:'
899 @$(ECHO) ' PATH_SDK_QT3 = "$(PATH_SDK_QT3)"'
900 @$(ECHO) ' PATH_SDK_QT3_INC = "$(PATH_SDK_QT3_INC)"'
901 @$(ECHO) ' PATH_SDK_QT3_LIB = "$(PATH_SDK_QT3_LIB)"'
902 @$(ECHO) ' PATH_SDK_QT3_LIB.amd64 = "$(PATH_SDK_QT3_LIB.amd64)"'
903 @$(ECHO) ' PATH_SDK_QT3_LIB.x86 = "$(PATH_SDK_QT3_LIB.x86)"'
904 @$(ECHO) 'The Qt3 TOOL variables:'
905 @$(ECHO) ' PATH_TOOL_QT3_BIN = "$(PATH_TOOL_QT3_BIN)"'
906 @$(ECHO) ' TOOL_QT3_BIN_SUFF = "$(TOOL_QT3_BIN_SUFF)"'
907 @$(ECHO) ' TOOL_QT3_MOC = "$(TOOL_QT3_MOC)"'
908 @$(ECHO) ' TOOL_QT3_UIC = "$(TOOL_QT3_UIC)"'
909 @$(ECHO) ' TOOL_QT3_LRC = "$(TOOL_QT3_LRC)"'
910 @$(ECHO) ' TOOL_QT3_LUPDATE = "$(TOOL_QT3_LUPDATE)"'
911
Note: See TracBrowser for help on using the repository browser.