source: trunk/kBuild/units/qt4.kmk

Last change on this file was 3284, checked in by bird, 7 years ago

footer-pass2-compiling-targets.kmk,units: Added a dedicated pass 2 variable for units to put their intermediates in so as to not mess with inheritance or for us to do silly things wrt expansion for every property variant. Only the new variable is now always listed as an order-only dependency for each source compilation rule.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.5 KB
RevLine 
[1671]1# $Id: qt4.kmk 3284 2019-01-05 01:40:31Z bird $
2## @file
[1676]3# Qt 4 unit.
[1671]4#
5
6#
[3121]7# Copyright (c) 2008-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
[1671]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#
[2018]26# As a special exception you are granted permission to include this file, via
27# the kmk include directive, as you wish without this in itself causing the
28# resulting makefile, program or whatever to be covered by the GPL license.
29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
[1671]33
[2018]34
[1682]35ifdef UNIT_qt4
36 $(error kBuild: The qt4 unit was included twice!)
37endif
[1671]38UNIT_qt4 = qt4
39
40
[2805]41if !defined(UNIT_qt3) && !defined(UNIT_qt5)
42 # Add our target properties (same as qt3 & qt5).
[1682]43 PROPS_SINGLE += QTTOOL MOCTOOL UICTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE QT_PREFIX
44 PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS LRCFLAGS QT_TRANSLATIONS QT_MOCSRCS QT_MOCHDRS
45endif
[2176]46PROPS_SINGLE += RCCTOOL QT_INFIX
[1682]47PROPS_ACCUMULATE_R += RCCFLAGS QT_MODULES
[1671]48
[1682]49
[1769]50## @todo use pkg-config?
51
[1671]52#
53# The QT4 SDK.
54#
55# This is implemented here rather than in sdks/QT4.kmk to enforce the global USES.
56# It also makes things easier to develop, with fewer files I mean.
57#
[1677]58## @todo the SDK might actually not be necessary as it turns out... For now it servers
59# a purpose if the host differs from the target, in theory at least.
[1671]60SDK_QT4 = Qt4
61
[1677]62# SDK Specific Properties
[1767]63# PATH_SDK_QT4 - The general Qt4 root directory.
64# PATH_SDK_QT4_INC - The include directory.
65# PATH_SDK_QT4_LIB.amd64 - The lib directory for AMD64.
66# PATH_SDK_QT4_LIB.x86 - The lib directory for X86.
67# PATH_SDK_QT4_LIB - The lib directory for KBUILD_TARGET.
[1677]68ifndef PATH_SDK_QT4
[2272]69 PATH_SDK_QT4 := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v4*)))
[1677]70 ifeq ($(PATH_SDK_QT4),)
71 # If target == host, try look for Qt in the various platform specific places.
72 ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
73 ifeq ($(KBUILD_TARGET),darwin)
74 PATH_SDK_QT4 := $(patsubst %/Frameworks/QtCore.framework/Versions/4,%,$(firstword $(wildcard /Library/Frameworks/QtCore.framework/Versions/4)))
75 else ifeq ($(KBUILD_TARGET),win)
76 # No idea here yet...
[1767]77 else ifeq ($(KBUILD_TARGET),ose)
78 # No port...
[1677]79 else
80 # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT4_LIB* stuff if it doesn't work.
[1767]81 # Try find the general root of thing by looking for the qt3to4 program, if not found, then look for rcc.
[2787]82 PATH_SDK_QT4 := $(patsubst %/bin/qt3to4-qt4,%,$(firstword $(wildcard \
83 /usr/bin/qt3to4-qt4 \
84 /usr/local/bin/qt3to4-qt4 \
85 /usr/qt/4/bin/qt3to4-qt4 \
86 /usr/share/qt4/bin/qt3to4-qt4 \
[1767]87 )))
88 ifeq ($(PATH_SDK_QT4),)
[2787]89 PATH_SDK_QT4 := $(patsubst %/bin/qt3to4,%,$(firstword $(wildcard \
90 /usr/bin/qt3to4 \
91 /usr/local/bin/qt3to4 \
92 /usr/qt/4/bin/qt3to4 \
93 /usr/share/qt4/bin/qt3to4 \
94 )))
95 endif
96 ifeq ($(PATH_SDK_QT4),)
97 PATH_SDK_QT4 := $(patsubst %/bin/rcc-qt4,%,$(firstword $(wildcard \
98 /usr/bin/rcc-qt4 \
99 /usr/local/bin/rcc-qt4 \
100 /usr/qt/4/bin/rcc-qt4 \
101 /usr/share/qt4/bin/rcc-qt4 \
102 )))
103 endif
104 ifeq ($(PATH_SDK_QT4),)
[1774]105 PATH_SDK_QT4 := $(patsubst %/bin/rcc,%,$(firstword $(wildcard \
[2975]106 /usr/lib/*/qt4/bin/rcc \
[1767]107 /usr/bin/rcc \
[2787]108 /usr/local/bin/rcc \
[1767]109 /usr/qt/4/bin/rcc \
110 /usr/share/qt4/bin/rcc \
[2787]111 )))
[1767]112 endif
[1677]113 ifneq ($(PATH_SDK_QT4),)
[1767]114 export PATH_SDK_QT4
[1773]115
[1767]116 # Locate the include files.
[1677]117 ifeq ($(PATH_SDK_QT4_INC),)
[1767]118 PATH_SDK_QT4_INC := $(patsubst %/QtCore/qglobal.h,%,$(firstword $(wildcard \
[2975]119 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt4/QtCore/qglobal.h) \
[1767]120 $(PATH_SDK_QT4)/include/QtCore/qglobal.h \
121 $(PATH_SDK_QT4)/include/qt4/QtCore/qglobal.h \
122 /usr/include/qt4/QtCore/qtglobal.h \
123 /usr/local/include/qt4/QtCore/qtglobal.h \
124 )))
[1773]125 ifneq ($(PATH_SDK_QT4_INC),)
126 export PATH_SDK_QT4_INC
127 endif
[1677]128 endif
[1767]129
130 # Now for the libraries (mostly for helping out finding the KBUILD_TARGET libs).
[1677]131 ifeq ($(PATH_SDK_QT4_LIB.x86),)
132 PATH_SDK_QT4_LIB.x86 := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
133 $(PATH_SDK_QT4)/lib32/libQtCore$(SUFF_DLL) \
134 $(PATH_SDK_QT4)/lib32/qt4/libQtCore$(SUFF_DLL) \
[1685]135 /usr/lib32/libQtCore$(SUFF_DLL) \
136 /usr/lib32/qt4/libQtCore$(SUFF_DLL) \
[2975]137 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
[1685]138 /usr/local/lib32/libQtCore$(SUFF_DLL) \
139 /usr/local/lib32/qt4/libQtCore$(SUFF_DLL) \
[2975]140 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
[1677]141 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
142 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
[2544]143 $(PATH_SDK_QT4)/lib/i386-linux-gnu/libQtCore$(SUFF_DLL) \
[1677]144 )))
[1767]145 ifneq ($(PATH_SDK_QT4_LIB.x86),)
146 export PATH_SDK_QT4_LIB.x86
147 endif
[1677]148 endif
149 ifeq ($(PATH_SDK_QT4_LIB.amd64),)
150 PATH_SDK_QT4_LIB.amd64 := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
151 $(PATH_SDK_QT4)/lib64/libQtCore$(SUFF_DLL) \
152 $(PATH_SDK_QT4)/lib64/qt4/libQtCore$(SUFF_DLL) \
153 $(PATH_SDK_QT4)/lib/amd64/libQtCore$(SUFF_DLL) \
[1685]154 /usr/lib64/libQtCore$(SUFF_DLL) \
155 /usr/lib64/qt4/libQtCore$(SUFF_DLL) \
156 /usr/lib/amd64/libQtCore$(SUFF_DLL) \
[2975]157 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
[1685]158 /usr/local/lib64/libQtCore$(SUFF_DLL) \
159 /usr/local/lib64/qt4/libQtCore$(SUFF_DLL) \
160 /usr/local/lib/amd64/libQtCore$(SUFF_DLL) \
[2975]161 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
[1677]162 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
163 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
[2544]164 $(PATH_SDK_QT4)/lib/x86_64-linux-gnu/libQtCore$(SUFF_DLL) \
[1677]165 )))
[1767]166 ifneq ($(PATH_SDK_QT4_LIB.amd64),)
167 export PATH_SDK_QT4_LIB.amd64
168 endif
[1677]169 endif
[1767]170
171 # And finally, the library path for KBUILD_TARGET.
[1677]172 ifeq ($(PATH_SDK_QT4_LIB),)
[2319]173 PATH_SDK_QT4_LIB := $(PATH_SDK_QT4_LIB.$(KBUILD_TARGET_ARCH))
[1677]174 ifeq ($(PATH_SDK_QT4_LIB),)
175 PATH_SDK_QT4_LIB := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
[1767]176 $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
177 $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
178 /usr/lib/libQtCore$(SUFF_DLL) \
179 /usr/lib/qt4/libQtCore$(SUFF_DLL) \
[2975]180 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
[1767]181 /usr/local/lib/libQtCore$(SUFF_DLL) \
182 /usr/local/lib/qt4/libQtCore$(SUFF_DLL) \
[2975]183 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
[1767]184 )))
[1677]185 endif
[1767]186 ifneq ($(PATH_SDK_QT4_LIB),)
187 export PATH_SDK_QT4_LIB
188 endif
[1677]189 endif
[1767]190
[1677]191 endif
192 endif # Unices
193 endif
194 # Found it?
195 ifeq ($(PATH_SDK_QT4),)
196 $(warning kBuild: Couldn't find the Qt4 headers and libaries...)
[2272]197 PATH_SDK_QT4 := $(KBUILD_DEVTOOLS_TRG)/qt/not-found
[1677]198 endif
199 endif
200else
201 # Resolve any fancy stuff once and for all.
202 PATH_SDK_QT4 := $(PATH_SDK_QT4)
203endif
[1671]204
[1677]205# Libraries can be in either Frameworks or lib depending on how you
206# build it on the mac. The .dmg installs into Frameworks but builds into lib.
207ifeq ($(KBUILD_TARGET),darwin)
208 ifndef PATH_SDK_QT4_LIB
209 ifneq ($(wildcard $(PATH_SDK_QT4)/Frameworks),)
210 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/Frameworks
211 else
212 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/lib
213 endif
214 endif
215else
216 PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/lib
217 PATH_SDK_QT4_INC ?= $(PATH_SDK_QT4)/include
218endif
219
220# The bits that kBuild picks up.
221# (nothing here)
222
223
[1671]224#
225# The QT4 tool.
226#
227# This is implemented here rather than in tools/QT4.kmk to enforce the global USES.
228# It also makes things easier to develop, with fewer files I mean.
229#
230TOOL_QT4 = Qt4
231
232# Tool Specific Properties
[1767]233# PATH_TOOL_QT4 - Obsolete.
[1773]234# PATH_TOOL_QT4_BIN - The
235# TOOL_QT4_BIN_SUFF -
[1767]236if !defined(PATH_TOOL_QT4_BIN) && defined(PATH_TOOL_QT4)
237 PATH_TOOL_QT4_BIN := $(PATH_TOOL_QT4)/bin
238endif
239ifndef PATH_TOOL_QT4_BIN
[2272]240 PATH_TOOL_QT4_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST)/qt/v4*/bin)))
241 if "$(PATH_TOOL_QT4_BIN)" == "" && "$(KBUILD_DEVTOOLS_HST_ALT)" != ""
242 PATH_TOOL_QT4_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST_ALT)/qt/v4*/bin)))
243 endif
[1767]244 ifeq ($(PATH_TOOL_QT4_BIN),)
245 ifdef TOOL_QT4_BIN_SUFF
246 TOOL_QT4_BIN_SUFF := $(TOOL_QT4_BIN_SUFF)
247 endif
[2976]248 # Try looking for moc-$(suffix) first, if specified.
[1774]249 ifneq ($(TOOL_QT4_BIN_SUFF),)
250 PATH_TOOL_QT4_BIN := $(patsubst %/moc$(TOOL_QT4_BIN_SUFF),%,$(firstword $(wildcard \
[2975]251 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/moc$(TOOL_QT4_BIN_SUFF)) \
[1774]252 /usr/lib/qt4/bin/moc$(TOOL_QT4_BIN_SUFF) \
253 /usr/qt/4/bin/moc$(TOOL_QT4_BIN_SUFF) \
254 /usr/share/qt4/bin/moc$(TOOL_QT4_BIN_SUFF) \
255 /usr/local/bin/moc$(TOOL_QT4_BIN_SUFF) \
256 /usr/bin/moc$(TOOL_QT4_BIN_SUFF) \
257 )))
258 else
[2976]259 # No suffix given, so before we check out -qt4 look at qt4 specific locations to avoid choosers and symlinks.
260 PATH_TOOL_QT4_BIN := $(patsubst %/moc,%,$(firstword $(wildcard \
[2978]261 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/moc) \
[2976]262 $(if $(intersects $(KBUILD_HOST_ARCH), $(KBUILD_ARCHES_64)),/usr/lib64/qt4/bin/moc,) \
263 /usr/lib/qt4/bin/moc \
264 /usr/local/lib/qt4/bin/moc \
265 /usr/qt/4/bin/moc \
266 /usr/local/qt/4/bin/moc \
267 /usr/share/qt4/bin/moc \
268 /usr/local/share/qt4/bin/moc \
[2977]269 )))
[2976]270 ifeq ($(PATH_TOOL_QT4_BIN),)
271 PATH_TOOL_QT4_BIN := $(patsubst %/moc-qt4,%,$(firstword $(wildcard \
272 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/moc-qt4) \
[1774]273 /usr/lib/qt4/bin/moc-qt4 \
274 /usr/qt/4/bin/moc-qt4 \
275 /usr/share/qt4/bin/moc-qt4 \
276 /usr/local/bin/moc-qt4 \
277 /usr/bin/moc-qt4 \
278 )))
[2976]279 ifneq ($(PATH_TOOL_QT4_BIN),)
280 TOOL_QT4_BIN_SUFF := -qt4
281 endif
[1767]282 endif
283 endif
[1774]284 # If still no go, try looking for qt3to4 and rcc.
285 ifeq ($(PATH_TOOL_QT4_BIN),)
286 PATH_TOOL_QT4_BIN := $(patsubst %/qt3to4,%,$(firstword $(wildcard \
[2975]287 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/qt3to4) \
[1774]288 /usr/lib/qt4/bin/qt3to4 \
289 /usr/qt/4/bin/qt3to4 \
290 /usr/share/qt4/bin/qt3to4 \
291 /usr/local/bin/qt3to4 \
292 /usr/bin/qt3to4 \
293 )))
294 endif
295 ifeq ($(PATH_TOOL_QT4_BIN),)
296 PATH_TOOL_QT4_BIN := $(patsubst %/rcc$(TOOL_QT4_BIN_SUFF),%,$(firstword $(wildcard \
[2975]297 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF)) \
[1774]298 /usr/lib/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
299 /usr/qt/4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
300 /usr/share/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
301 /usr/local/bin/rcc$(TOOL_QT4_BIN_SUFF) \
302 /usr/bin/rcc$(TOOL_QT4_BIN_SUFF) \
303 )))
304 endif
305 if "$(PATH_TOOL_QT4_BIN)" == "" && "$(TOOL_QT4_BIN_SUFF)" != ""
306 PATH_TOOL_QT4_BIN := $(patsubst %/rcc,%,$(firstword $(wildcard \
[2975]307 $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/rcc) \
[1774]308 /usr/lib/qt4/bin/rcc \
309 /usr/qt/4/bin/rcc \
310 /usr/share/qt4/bin/rcc \
311 /usr/local/bin/rcc \
312 /usr/bin/rcc \
313 )))
314 endif
315 ifneq ($(PATH_TOOL_QT4_BIN),)
316 export PATH_TOOL_QT4_BIN
317 endif
[1687]318 endif
[1671]319 # If not found, we'll enter the 'pathless' mode.
320else
321 # Resolve any fancy stuff once and for all.
[1767]322 PATH_TOOL_QT4_BIN := $(PATH_TOOL_QT4_BIN)
[1671]323endif
[1768]324ifneq ($(PATH_TOOL_QT4_BIN),)
[1767]325 TOOL_QT4_MOC ?= $(PATH_TOOL_QT4_BIN)/moc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
326 TOOL_QT4_UIC ?= $(PATH_TOOL_QT4_BIN)/uic$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
[1774]327 ifndef TOOL_QT4_RCC
328 TOOL_QT4_RCC := $(PATH_TOOL_QT4_BIN)/rcc$(HOST_SUFF_EXE)
329 ifeq ($(wildcard $(TOOL_QT4_RCC)),)
330 TOOL_QT4_RCC := $(PATH_TOOL_QT4_BIN)/rcc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
331 endif
332 endif
[1767]333 TOOL_QT4_LRC ?= $(PATH_TOOL_QT4_BIN)/lrelease$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
334 TOOL_QT4_LUPDATE ?= $(PATH_TOOL_QT4_BIN)/lupdate$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
[1671]335else
336 # Pathless, relies on the environment.
[1767]337 TOOL_QT4_MOC ?= moc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
338 TOOL_QT4_UIC ?= uic$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
[2979]339 TOOL_QT4_RCC ?= rcc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
[1767]340 TOOL_QT4_LRC ?= lrelease$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
341 TOOL_QT4_LUPDATE ?= lupdate$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
[1671]342endif
343
344# General Properties used by kBuild and/or units/qt.kmk
345TOOL_QT4_MOCFLAGS ?=
346TOOL_QT4_MOCINCS ?=
347TOOL_QT4_MOCDEFS ?=
348TOOL_QT4_MOCDEFS.darwin ?= __APPLE__ __GNUC__
349TOOL_QT4_MOCDEFS.solaris ?= __sun
350TOOL_QT4_MOCDEFS.win.amd64 ?= WIN64
351TOOL_QT4_MOCDEFS.win.x86 ?= WIN32
352
353
354## MOC a C++ source file.
355# @param $(target) Normalized main target name.
356# @param $(source) Source filename (relative).
357# @param $(out) Object file name. This shall be (re)created by the compilation.
358# @param $(dep) Dependcy file. This may be (re)created by the compilation.
359# @param $(flags) Flags.
360# @param $(defs) Definitions.
361# @param $(incs) Includes.
362# @param $(outbase) Output basename (full). Use this for list files and such.
363#
364TOOL_QT4_MOC_CPP_DEPEND =
365TOOL_QT4_MOC_CPP_DEPORD =
366TOOL_QT4_MOC_CPP_OUTPUT =
367TOOL_QT4_MOC_CPP_OUTPUT_MAYBE =
368define TOOL_QT4_MOC_CPP_CMDS
369 $(QUIET)$(TOOL_QT4_MOC)\
370 $(flags)\
371 $(addprefix -I, $(incs))\
372 $(addprefix -D, $(defs))\
373 -o $(out)\
374 $(source)
375endef
376
377## MOC a C++ header file.
378# @param $(target) Normalized main target name.
379# @param $(source) Source filename (relative).
380# @param $(out) Object file name. This shall be (re)created by the compilation.
381# @param $(dep) Dependcy file. This may be (re)created by the compilation.
382# @param $(flags) Flags.
383# @param $(defs) Definitions.
384# @param $(incs) Includes.
385# @param $(outbase) Output basename (full). Use this for list files and such.
386#
387TOOL_QT4_MOC_HPP_DEPEND =
388TOOL_QT4_MOC_HPP_DEPORD =
389TOOL_QT4_MOC_HPP_OUTPUT =
390TOOL_QT4_MOC_HPP_OUTPUT_MAYBE =
391define TOOL_QT4_MOC_HPP_CMDS
392 $(QUIET)$(TOOL_QT4_MOC)\
393 $(flags)\
394 $(addprefix -I, $(incs))\
395 $(addprefix -D, $(defs))\
396 -o $(out)\
397 $(source)
398endef
399
400## Compile a Qt user interface file (.ui).
401# @param $(target) Normalized main target name.
402# @param $(source) Source filename (relative).
403# @param $(out) Object file name. This shall be (re)created by the compilation.
404# @param $(dep) Dependcy file. This may be (re)created by the compilation.
405# @param $(flags) Flags.
406# @param $(defs) Definitions.
407# @param $(incs) Includes.
408# @param $(outbase) Output basename (full). Use this for list files and such.
409#
410TOOL_QT4_UIC_UI_DEPEND =
411TOOL_QT4_UIC_UI_DEPORD =
412TOOL_QT4_UIC_UI_OUTPUT =
413TOOL_QT4_UIC_UI_OUTPUT_MAYBE =
414define TOOL_QT4_UIC_UI_CMDS
415 $(QUIET)$(TOOL_QT4_UIC)\
416 $(flags)\
417 -o $(out)\
418 $(source)
419endef
420
421## Compile a Qt resource file (.qrc).
422# @param $(target) Normalized main target name.
423# @param $(source) Source filename (relative).
424# @param $(out) Object file name. This shall be (re)created by the compilation.
425# @param $(dep) Dependcy file. This may be (re)created by the compilation.
426# @param $(flags) Flags.
427# @param $(defs) Definitions.
428# @param $(incs) Includes.
429# @param $(outbase) Output basename (full). Use this for list files and such.
430#
431# @remarks The sed script generating the dependency file is a bit naive.
432TOOL_QT4_RCC_QRC_DEPEND =
433TOOL_QT4_RCC_QRC_DEPORD =
434TOOL_QT4_RCC_QRC_OUTPUT =
435TOOL_QT4_RCC_QRC_OUTPUT_MAYBE =
436define TOOL_QT4_RCC_QRC_CMDS
437 $(QUIET)$(TOOL_QT4_RCC)\
438 $(flags)\
439 -o $(out)\
440 $(source)
[2361]441 $(QUIET2)$(APPEND) $(dep) '\'
442 $(QUIET2)$(APPEND) $(dep) '$(out): \'
443 $(QUIET2)$(APPEND) $(dep) '$(source) \'
444 $(QUIET2)$(SED) \
[1671]445 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
446 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
[2183]447 -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
[1671]448 -e 's|$$$$| \\|' \
449 --append $(dep) \
450 $(source)
[2361]451 $(QUIET2)$(APPEND) $(dep)
452 $(QUIET2)$(SED) \
[1671]453 -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
454 -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
[2183]455 -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
[1671]456 -e 's|$$$$|:\n|' \
457 --append $(dep) \
458 $(source)
[2361]459 $(QUIET2)$(APPEND) $(dep)
[1671]460endef
461
[1675]462## Compile a Qt translation file (.ts).
463# @param $(target) Normalized main target name.
464# @param $(source) Source filename (relative).
465# @param $(out) Object file name. This shall be (re)created by the compilation.
466# @param $(dep) Dependcy file. This may be (re)created by the compilation.
467# @param $(flags) Flags.
468# @param $(defs) Definitions.
469# @param $(incs) Includes.
470# @param $(outbase) Output basename (full). Use this for list files and such.
471#
472TOOL_QT4_LRC_TS_DEPEND =
473TOOL_QT4_LRC_TS_DEPORD =
474TOOL_QT4_LRC_TS_OUTPUT =
475TOOL_QT4_LRC_TS_OUTPUT_MAYBE =
476define TOOL_QT4_LRC_TS_CMDS
477 $(QUIET)$(TOOL_QT4_LRC)\
478 $(flags)\
479 $(source)\
480 -qm $(out)
481endef
[1671]482
483
[1675]484
[1671]485#
486#
487# Back to the Qt4 unit.
488#
489#
490
491
[1675]492## wrapper for the lrelease (LRC) command dependencies.
493ifndef NO_COMPILE_CMDS_DEPS
[1683]494 _UNIT_QT4_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
[1675]495else
[1683]496 _UNIT_QT4_LRC_CMDS_DEP =
[1675]497endif
498
[1671]499##
[1675]500# def_unit_qt4_target_pre_handle_translation helper that is expanded before evaluation.
[1671]501#
[1675]502# This is necessary to resolve reference to local variables before doing
503# assignments and setting up commands. They would otherwise be resolved
504# later in a different context and the result would be completely wrong.
505#
506define def_unit_qt4_target_pre_handle_translation_dx
[1671]507
[1675]508$(out) + $(more_output) +| $(maybe_output): \
509 $(deps) \
[1683]510 $(value _UNIT_QT4_LRC_CMDS_DEP) \
[1675]511 | \
512 $(orderdeps)
513 %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
514 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
[1671]515
[1675]516$(cmds)
517
518ifndef NO_COMPILE_CMDS_DEPS
519 %$$(QUIET2)$$(APPEND) '$(dep)'
[1683]520 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_'
[1675]521 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
522 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
523endif
524
[2197]525$(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
[1675]526$(target)-inst-nls_SOURCES += $(out)
527
528endef # def_unit_qt4_target_pre_handle_translation_dx
529
530##
531# Handle a source file listed in QT_TRANSLATIONS.
532#
533# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
534# to be translated into .qm files that are loadble by Qt.
535#
536# @remarks Invoked via $(evalvalctx ).
537define def_unit_qt4_target_pre_handle_translation
538local type := LRC
539
540# fetch the properties.
541local tool := $(kb-src-tool dummy_var)
[2239]542local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
[1675]543local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
544local out := $(outbase).qm
545local dep := $(out).dep
546local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
547local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
548local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
549
550# default path + source dep.
551ifneq ($(defpath),)
[1771]552local source := $(abspathex $(source),$(defpath))
553local deps := $(abspathex $(deps),$(defpath)) $(source)
554local incs := $(abspathex $(incs),$(defpath))
[1675]555else
556local deps += $(source)
557endif
558
559# call the tool
560ifndef TOOL_$(tool)_LRC_TS_CMDS
561 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
562endif
563local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
564local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
565local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
566local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
567local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
568
569# generate the link rule and update some source and target variables.
570ifndef NO_COMPILE_CMDS_DEPS
571 $(eval includedep $(dep))
572endif
573$(eval $(def_unit_qt4_target_pre_handle_translation_dx))
574
575endef # def_unit_qt4_target_pre_handle_translation
576
577
578
[1671]579## wrapper for the UIC command dependencies.
580ifndef NO_COMPILE_CMDS_DEPS
[1683]581 _UNIT_QT4_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
[1671]582else
[1683]583 _UNIT_QT4_RCC_CMDS_DEP =
[1671]584endif
585
586##
587# def_unit_qt4_target_pre_handle_qrc helper that is expanded before evaluation.
588#
589# This is necessary to resolve reference to local variables before doing
590# assignments and setting up commands. They would otherwise be resolved
591# later in a different context and the result would be completely wrong.
592#
593define def_unit_qt4_target_pre_handle_rcc_dx
594
595$(out) +| $(realout) $(more_output) $(maybe_output): \
596 $(deps) \
[1683]597 $(value _UNIT_QT4_RCC_CMDS_DEP) \
[1671]598 | \
599 $(orderdeps)
600 %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
601 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
602
603$(cmds)
604
605 $(QUIET)$(CP) --changed -f $(out) $(realout)
606ifndef NO_COMPILE_CMDS_DEPS
607 %$$(QUIET2)$$(APPEND) '$(dep)'
[1683]608 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_'
[1671]609 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
610 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
611endif
612
[3284]613$(target)_2_INTERMEDIATES += $(realout)
[1671]614$(target)_GEN_SOURCES_ += $(realout)
[2197]615$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
[1671]616
617endef # def_unit_qt4_target_pre_handle_rcc_dx
618
619##
620# Source handler for .qrc sources (Qt resource files).
621#
622# @remarks $(evalvalctx me).
623define def_unit_qt4_src_handler_qrc
624local type := RCC
625
626# fetch the properties.
627local tool := $(kb-src-tool dummy_var)
[2239]628local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
[1671]629local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
630local out := $(outbase).tmp.gen.cpp
631local realout := $(outbase).gen.cpp
632local dep := $(realout).dep
633local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
634local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
635local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
636
637# default path + source dep.
638ifneq ($(defpath),)
[1771]639local source := $(abspathex $(source),$(defpath))
640local deps := $(abspathex $(deps),$(defpath)) $(source)
641local incs := $(abspathex $(incs),$(defpath))
[1671]642else
643local deps += $(source)
644endif
645
646# call the tool
647ifndef TOOL_$(tool)_RCC_QRC_CMDS
648 $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
649endif
650local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
651local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
652local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
653local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
654local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
655
656# generate the link rule and update some source and target variables.
657ifndef NO_COMPILE_CMDS_DEPS
658 $(eval includedep $(dep))
659endif
660$(eval $(def_unit_qt4_target_pre_handle_rcc_dx))
661
662endef # def_unit_qt4_src_handler_qrc
663
664
[1675]665
[1671]666## wrapper for the UIC command dependencies.
667ifndef NO_COMPILE_CMDS_DEPS
[1683]668 _UNIT_QT4_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
[1671]669else
[1683]670 _UNIT_QT4_UIC_CMDS_DEP =
[1671]671endif
672
673##
[1675]674# def_unit_qt4_src_handler_ui helper that is expanded before evaluation.
[1671]675#
676# This is necessary to resolve reference to local variables before doing
677# assignments and setting up commands. They would otherwise be resolved
678# later in a different context and the result would be completely wrong.
679#
680define def_unit_qt4_target_pre_handle_ui_dx
681
682$(out) +| $(realout) $(more_output) $(maybe_output): \
683 $(deps) \
[1683]684 $(value _UNIT_QT4_UIC_CMDS_DEP) \
[1671]685 | \
686 $(orderdeps)
687 %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
688 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
689
690$(cmds)
691
692 $(QUIET)$(CP) --changed -f $(out) $(realout)
693ifndef NO_COMPILE_CMDS_DEPS
694 %$$(QUIET2)$$(APPEND) '$(dep)'
[1683]695 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_'
[1671]696 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
697 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
698endif
699
[3284]700$(target)_2_INTERMEDIATES += $(realout)
[2197]701$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
[1671]702
703endef # def_unit_qt4_target_pre_handle_ui_dx
704
705##
706# Source handler for .ui sources.
707#
708# @remarks $(evalvalctx me).
709define def_unit_qt4_src_handler_ui
710local type := UIC
711
712# fetch the properties.
713local tool := $(kb-src-tool dummy_var)
[2239]714local qtuicdir := $($(target)_0_OUTDIR)/qtuic
[1671]715local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
716local out := $(outbase).tmp.gen.h
717local realout := $(outbase).gen.h
718local dep := $(realout).dep
719local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
720local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
721local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
722
723# default path + source dep.
724ifneq ($(defpath),)
[1771]725local source := $(abspathex $(source),$(defpath))
726local deps := $(abspathex $(deps),$(defpath)) $(source)
727local incs := $(abspathex $(incs),$(defpath))
[1671]728else
729local deps += $(source)
730endif
731
732# call the tool
733ifndef TOOL_$(tool)_UIC_UI_CMDS
734 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
735endif
736local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
737local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
738local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
739local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
740local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
741
742# generate the link rule and update some source and target variables.
743ifndef NO_COMPILE_CMDS_DEPS
744 $(eval includedep $(dep))
745endif
746$(eval $(def_unit_qt4_target_pre_handle_ui_dx))
747
748endef # def_unit_qt4_src_handler_ui
749
750
[1675]751
[1671]752## wrapper for the MOC command dependencies.
753ifndef NO_COMPILE_CMDS_DEPS
[1683]754 _UNIT_QT4_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
[1671]755else
[1683]756 _UNIT_QT4_MOC_HPP_CMDS_DEP =
[1671]757endif
758
759##
760# def_unit_qt4_target_pre_handle_moc_hdr helper that is expanded before evaluation.
761#
762# This is necessary to resolve reference to local variables before doing
763# assignments and setting up commands. They would otherwise be resolved
764# later in a different context and the result would be completely wrong.
765#
766define def_unit_qt4_target_pre_handle_moc_hdr_dx
767
768$(out) +| $(realout) $(more_output) $(maybe_output): \
769 $(deps) \
[1683]770 $(value _UNIT_QT4_MOC_HPP_CMDS_DEP) \
[1671]771 | \
772 $(orderdeps)
773 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
774 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
775
776$(cmds)
777
778 $(QUIET)$(CP) --changed -f $(out) $(realout)
779ifndef NO_COMPILE_CMDS_DEPS
780 %$$(QUIET2)$$(APPEND) '$(dep)'
[1683]781 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_'
[1671]782 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
783 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
784endif
785
[3284]786$(target)_2_INTERMEDIATES += $(realout)
[1671]787$(target)_GEN_SOURCES_ += $(realout)
[2197]788$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
[1671]789
790endef
791
792##
[1683]793# Handle a source file listed in QT_MOCHDRS.
[1671]794#
[1675]795# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
796# generate a .cpp file for each of them and add it to the generated
797# sources so that it's compiled and linked. (There is an alternative
798# way to do this where the .cpp file is included, this isn't currently
799# supported by this unit.)
[1671]800#
801# @remarks Invoked via $(evalvalctx ).
802define def_unit_qt4_target_pre_handle_moc_hdr
803local type := MOC
804
805# fetch the properties.
806local tool := $(kb-src-tool dummy_var)
807local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
808local out := $(outbase).tmp.cpp
809local realout := $(outbase).cpp
810local dep := $(realout).dep
811local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
812local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
813local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
814local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
815local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
816
817# default path + source dep.
818ifneq ($(defpath),)
[1771]819local source := $(abspathex $(source),$(defpath))
820local deps := $(abspathex $(deps),$(defpath)) $(source)
821local incs := $(abspathex $(incs),$(defpath))
[1671]822else
823local deps += $(source)
824endif
825
826# call the tool
827ifndef TOOL_$(tool)_MOC_HPP_CMDS
828 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
829endif
830local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
831local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
832local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
833local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
834local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
835
836# generate the link rule and update some source and target variables.
837ifndef NO_COMPILE_CMDS_DEPS
838 $(eval includedep $(dep))
839endif
840$(eval $(def_unit_qt4_target_pre_handle_moc_hdr_dx))
841
842endef # def_unit_qt4_target_pre_handle_moc_hdr
843
844
[1683]845## wrapper for the MOC command dependencies.
846ifndef NO_COMPILE_CMDS_DEPS
847 _UNIT_QT4_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
848else
849 _UNIT_QT4_MOC_CPP_CMDS_DEP =
850endif
851
[1671]852##
853# def_unit_qt4_target_pre_handle_moc_src helper that is expanded before evaluation.
854#
855# This is necessary to resolve reference to local variables before doing
856# assignments and setting up commands. They would otherwise be resolved
857# later in a different context and the result would be completely wrong.
858#
859define def_unit_qt4_target_pre_handle_moc_src_dx
860
861$(out) +| $(realout) $(more_output) $(maybe_output): \
862 $(deps) \
[1683]863 $(value _UNIT_QT4_MOC_CPP_CMDS_DEP) \
[1671]864 | \
865 $(orderdeps)
866 %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
867 $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
868
869$(cmds)
870
871 $(QUIET)$(CP) --changed -f $(out) $(realout)
872ifndef NO_COMPILE_CMDS_DEPS
873 %$$(QUIET2)$$(APPEND) '$(dep)'
[1683]874 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_'
[1671]875 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
876 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
877endif
878
[3284]879$(target)_2_INTERMEDIATES += $(realout)
[2197]880$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
[1671]881
882endef
883
884##
885# Handle a source file listed in QT_MOCSRCS.
886#
887# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
888# a .moc file that we're expected to generate here.
889#
890# @remarks Invoked via $(evalvalctx ).
891define def_unit_qt4_target_pre_handle_moc_src
892local type := MOC
893
894# fetch the properties.
895local tool := $(kb-src-tool dummy_var)
896local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
897local out := $(outbase).tmp.moc
898local realout := $(outbase).moc
899local dep := $(realout).dep
900local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
901local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
902local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
903local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
904local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
905
906# default path + source dep.
907ifneq ($(defpath),)
[1771]908local source := $(abspathex $(source),$(defpath))
909local deps := $(abspathex $(deps),$(defpath)) $(source)
910local incs := $(abspathex $(incs),$(defpath))
[1671]911else
912local deps += $(source)
913endif
914
915# call the tool
916ifndef TOOL_$(tool)_MOC_CPP_CMDS
917 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
918endif
919local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
920local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
921local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
922local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
923local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
924
925# generate the link rule and update some source and target variables.
926ifndef NO_COMPILE_CMDS_DEPS
927 $(eval includedep $(dep))
928endif
929$(eval $(def_unit_qt4_target_pre_handle_moc_src_dx))
930
931endef # def_unit_qt4_target_pre_handle_moc_src
932
933
934##
935# Adds sources containing Q_OBJECT to QT_MOCSRCS.
936define def_unit_qt4_target_pre_cpp_source
937ifneq ($(file-size $(source)),-1)
938 ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
939 $(eval $(target)_QT_MOCSRCS += $(source))
940 endif
941endif
942endef # def_unit_qt4_target_pre_cpp_source
943
944##
945# Invoked early in the processing of a target that uses the Qt unit.
946#
947# It will append the qt source handlers to the target (.h, .ui, .ts,
948# .png, .bmp, .gif).
949#
950# It will then check all the C++ sources and check which needs
951# a .moc files and generate rules and dependencies fofor these
952#
953define def_unit_qt4_target_pre
954
[1675]955# Make QTTOOL the default for the specific Qt tools instead of TOOL.
956ifneq ($($(target)_QTTOOL),)
957 ifeq ($($(target)_MOCTOOL),)
[1682]958 $(target)_MOCTOOL := $($(target)_QTTOOL)
[1675]959 endif
960 ifeq ($($(target)_UICTOOL),)
[1682]961 $(target)_UICTOOL := $($(target)_QTTOOL)
[1675]962 endif
963 ifeq ($($(target)_RCCTOOL),)
[1682]964 $(target)_RCCTOOL := $($(target)_QTTOOL)
[1675]965 endif
966 ifeq ($($(target)_LRCTOOL),)
[1682]967 $(target)_LRCTOOL := $($(target)_QTTOOL)
[1675]968 endif
969endif
970
[2176]971# Deal with QT_MODULES, QT_PREFIX and QT_INFIX.
[1677]972local qt_modules := \
[1761]973 $($(target)_QT_MODULES.$(bld_trg)) \
974 $($(target)_QT_MODULES.$(bld_trg_arch)) \
975 $($(target)_QT_MODULES.$(bld_trg).$(bld_trg_arch)) \
976 $($(target)_QT_MODULES.$(bld_trg_cpu)) \
977 $($(target)_QT_MODULES.$(bld_type)) \
[1677]978 $($(target)_QT_MODULES)
979local qt_prefix := $(firstword \
[1761]980 $($(target)_QT_PREFIX.$(bld_trg)) \
981 $($(target)_QT_PREFIX.$(bld_trg_arch)) \
982 $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
983 $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
984 $($(target)_QT_PREFIX.$(bld_type)) \
[1677]985 $($(target)_QT_PREFIX))
[2176]986local qt_infix := $(firstword \
987 $($(target)_QT_INFIX.$(bld_trg)) \
988 $($(target)_QT_INFIX.$(bld_trg_arch)) \
989 $($(target)_QT_INFIX.$(bld_trg).$(bld_trg_arch)) \
990 $($(target)_QT_INFIX.$(bld_trg_cpu)) \
991 $($(target)_QT_INFIX.$(bld_type)) \
992 $($(target)_QT_INFIX))
[1677]993ifeq ($(bld_trg),darwin)
[1681]994 # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
995 $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT4_LIB) )
[2358]996 $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT4_LIB) )
[2176]997 $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT4_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) )
998 $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/4/Headers) )
[1677]999else
[1679]1000 ifeq ($(bld_trg),win)
[2245]1001 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)$(qt_infix)4$(SUFF_LIB)) )
[1681]1002 ifeq ($(tool_do),LINK_PROGRAM)
[2245]1003 $(eval $(target)_LIBS += $(PATH_SDK_QT4_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) )
[1681]1004 endif
[1679]1005 else
[2176]1006 $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/lib$(qt_prefix)Qt$(module)$(qt_infix)$(SUFF_DLL)) )
[1679]1007 endif
[1681]1008 $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT4_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT4_INC) )
[1677]1009endif
[1681]1010$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
[1677]1011
1012
[1671]1013# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
1014# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
1015ifndef $(target)_QT_MOCSRCS
1016 $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
[1761]1017 $($(target)_SOURCES.$(bld_trg)) \
1018 $($(target)_SOURCES.$(bld_trg_arch)) \
1019 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1020 $($(target)_SOURCES.$(bld_trg_cpu)) \
1021 $($(target)_SOURCES.$(bld_type)) \
[1671]1022 $($(target)_SOURCES) \
1023 ), $(evalval def_unit_qt4_target_pre_cpp_source))
1024endif
1025
1026# Install source handlers for .ui files.
1027$(target)_SRC_HANDLERS += \
1028 .ui:def_unit_qt4_src_handler_ui \
1029 .UI:def_unit_qt4_src_handler_ui \
1030 .qrc:def_unit_qt4_src_handler_qrc \
[1675]1031 .qrc:def_unit_qt4_src_handler_qrc
[1671]1032
1033# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
[2239]1034local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
1035local qtuicdir := $($(target)_0_OUTDIR)/qtuic
1036local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
1037local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
[1675]1038$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
1039$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
[1671]1040
1041# Deal with QT_MOCSRCS.
1042$(foreach source, \
[1761]1043 $($(target)_QT_MOCSRCS.$(bld_trg)) \
1044 $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
1045 $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
1046 $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
1047 $($(target)_QT_MOCSRCS.$(bld_type)) \
[1671]1048 $($(target)_QT_MOCSRCS) \
1049 , $(evalvalctx def_unit_qt4_target_pre_handle_moc_src))
1050
1051# Deal with QT_MOCHDRS.
1052$(foreach source, \
[1761]1053 $($(target)_QT_MOCHDRS.$(bld_trg)) \
1054 $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
1055 $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
1056 $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
1057 $($(target)_QT_MOCHDRS.$(bld_type)) \
[1671]1058 $($(target)_QT_MOCHDRS) \
1059 , $(evalvalctx def_unit_qt4_target_pre_handle_moc_hdr))
1060
[1675]1061# Deal with QT_TRANSLATIONS.
1062# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
1063local translations := \
[1761]1064 $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
1065 $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
1066 $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
1067 $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
1068 $($(target)_QT_TRANSLATIONS.$(bld_type)) \
[1675]1069 $($(target)_QT_TRANSLATIONS)
1070ifneq ($(strip $(translations)),)
[2479]1071 local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
[1675]1072 $(eval $(expr))
1073 ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
1074 $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
[1688]1075 else
1076 $(target)-inst-nls_MODE := 0644
[1675]1077 endif
1078 ifdef $(target)_QT_TRANSLATIONS_INST
1079 $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
1080 endif
1081 $(target)-inst-nls_SOURCES :=
1082 $(foreach source, $(translations)\
1083 , $(evalvalctx def_unit_qt4_target_pre_handle_translation))
1084endif
1085
[1671]1086endef # def_unit_qt4_target_pre
1087
[1767]1088
1089#
1090# Rule for debugging.
1091#
1092unit-qt4-show-vars:
1093 @$(ECHO) 'The Qt4 SDK variables:'
1094 @$(ECHO) ' PATH_SDK_QT4 = "$(PATH_SDK_QT4)"'
1095 @$(ECHO) ' PATH_SDK_QT4_INC = "$(PATH_SDK_QT4_INC)"'
1096 @$(ECHO) ' PATH_SDK_QT4_LIB = "$(PATH_SDK_QT4_LIB)"'
1097 @$(ECHO) ' PATH_SDK_QT4_LIB.amd64 = "$(PATH_SDK_QT4_LIB.amd64)"'
1098 @$(ECHO) ' PATH_SDK_QT4_LIB.x86 = "$(PATH_SDK_QT4_LIB.x86)"'
1099 @$(ECHO) 'The Qt4 TOOL variables:'
1100 @$(ECHO) ' PATH_TOOL_QT4_BIN = "$(PATH_TOOL_QT4_BIN)"'
1101 @$(ECHO) ' TOOL_QT4_BIN_SUFF = "$(TOOL_QT4_BIN_SUFF)"'
1102 @$(ECHO) ' TOOL_QT4_MOC = "$(TOOL_QT4_MOC)"'
1103 @$(ECHO) ' TOOL_QT4_UIC = "$(TOOL_QT4_UIC)"'
1104 @$(ECHO) ' TOOL_QT4_RCC = "$(TOOL_QT4_RCC)"'
1105 @$(ECHO) ' TOOL_QT4_LRC = "$(TOOL_QT4_LRC)"'
1106 @$(ECHO) ' TOOL_QT4_LUPDATE = "$(TOOL_QT4_LUPDATE)"'
[1769]1107
Note: See TracBrowser for help on using the repository browser.