summaryrefslogtreecommitdiffstats
path: root/kBuild/units
diff options
context:
space:
mode:
Diffstat (limited to 'kBuild/units')
-rw-r--r--kBuild/units/dtrace.kmk252
-rw-r--r--kBuild/units/gccprecomp.kmk67
-rw-r--r--kBuild/units/lex.kmk153
-rw-r--r--kBuild/units/qt-Q_OBJECT.sed36
-rw-r--r--kBuild/units/qt3.kmk947
-rw-r--r--kBuild/units/qt4.kmk1107
-rw-r--r--kBuild/units/qt5.kmk1214
-rw-r--r--kBuild/units/qt6.kmk1244
-rw-r--r--kBuild/units/vccprecomp.kmk66
-rw-r--r--kBuild/units/yacc.kmk198
10 files changed, 5284 insertions, 0 deletions
diff --git a/kBuild/units/dtrace.kmk b/kBuild/units/dtrace.kmk
new file mode 100644
index 0000000..9625895
--- /dev/null
+++ b/kBuild/units/dtrace.kmk
@@ -0,0 +1,252 @@
+# $Id: dtrace.kmk 3284 2019-01-05 01:40:31Z bird $
+## @file
+# DTrace unit.
+#
+
+#
+# Copyright (c) 2012-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+ifdef UNIT_dtrace
+ $(error kBuild: The dtrace unit was included twice!)
+endif
+UNIT_dtrace = dtrace
+
+# Add our target properties.
+PROPS_TOOLS += DTRACETOOL
+PROPS_SINGLE += DTRACETOOL
+PROPS_ACCUMULATE_R += DTRACE_HDR_FLAGS DTRACE_OBJ_FLAGS
+
+# Add ourselves to the default source handlers.
+KBUILD_SRC_HANDLERS += \
+ .d:def_src_handler_dtrace
+
+
+## wrapper the compile command dependency check.
+ifndef NO_COMPILE_CMDS_DEPS
+ _DEP_DTRACE_HDR_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_DTRACE_HDR_CMDS_PREV_),$$(commands $(out)),FORCE)
+ _DEP_DTRACE_OBJ_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_DTRACE_OBJ_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _DEP_DTRACE_HDR_CMDS =
+ _DEP_DTRACE_OBJ_CMDS =
+endif
+
+
+##
+# Generates the rule for creating a DTrace header from a D source file.
+#
+# @param out The output file.
+# @param cmds The dtrace command(s).
+# @param lots more
+#
+define def_dtrace_hdr_rule
+$(out): \
+ $(deps) \
+ $(value _DEP_DTRACE_HDR_CMDS) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_GENERATE,$(target),$$@,$(source))
+ $$(QUIET)$$(RM) -f -- $(dep) $(out)
+
+$(cmds)
+
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_DTRACE_HDR_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_DTRACE_HDR_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+# update globals
+_OUT_FILES += $(out)
+$(target)_2_INTERMEDIATES += $(out)
+
+endef # def_dtrace_hdr_rule
+
+
+##
+# Generates the rule for creating a DTrace object file from a D source file
+# and a bunch of object files.
+#
+# @param out The output file.
+# @param cmds The dtrace command(s).
+# @param lots more
+#
+define def_dtrace_obj_rule
+$(out): \
+ $(deps) \
+ $$$$(filter-out %-dtrace-object-format.o, $$$$($(target)_2_OBJS)) \
+ $(value _DEP_DTRACE_OBJ_CMDS) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_GENERATE,$(target),$$@,$(source) ++)
+ $$(QUIET)$$(RM) -f -- $(dep) $(out)
+
+$(cmds)
+
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_DTRACE_OBJ_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_DTRACE_OBJ_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+# update globals
+_OUT_FILES += $(out)
+$(target)_2_OBJS <= $(out)
+
+endef # def_dtrace_obj_rule
+
+
+##
+# Handler for .d files listed in the SOURCES properties.
+#
+# .d files are transformed into .h that is used when compiling, thus needing
+# to be generated before anything is compiled, and into object files that needs
+# to go into the linking. Mac does not create object files.
+#
+# The step producing the object file requires all the object files with dtrace
+# probes in them as input/output as well, because it adjusts the dtrace symbols
+# from UNDEF to IGNORE. This is really ugly and cannot be expressed in make
+# syntax (prerequisite object files being modified). Fortunately, it works
+# fine because the object files won't be used by anyone else before the dtrace
+# object file exists.
+#
+# @param target The target file.
+# @param source The source file.
+# @param lots more
+# @returns quite a bit.
+define def_src_handler_dtrace
+
+local type := DTRACE
+local tmp := $(kb-src-tool tool)
+ifeq ($(tool),)
+$ (error kBuild: $(target) / $(sources) does not have a (DTRACE) tool defined!)
+endif
+local dtracedir := $($(target)_0_OUTDIR)/dtrace
+
+#
+# The header file first.
+#
+
+# Figure out all the props.
+ifndef TOOL_$(tool)_DTRACE_HDR_CMDS
+$(error kBuild: TOOL_$(tool)_DTRACE_HDR_CMDS isn't defined! target=$(target) source=$(source) )
+endif
+## @todo put the header in a subdir and add this to INCS? Do we have a early per-target hook for this??
+local outbase := $(dtracedir)/dtrace/$(basename $(notdir $(source)))
+local out := $(outbase).h
+local tmp := $(kb-src-prop DTRACE_HDR_FLAGS,flags,left-to-right,)
+local tmp := $(kb-src-prop DEPS,deps,left-to-right,$(defpath))
+local tmp := $(kb-src-prop ORDERDEPS,orderdeps,left-to-right,$(defpath))
+local dirdep := $(call DIRDEP,$(dir $(out)))
+
+# Adjust paths if we got a default path.
+ifneq ($(defpath),)
+ local source := $(abspathex $(source),$(defpath))
+endif
+
+# dependency file.
+local dep := $(out)$(SUFF_DEP)
+ifndef NO_COMPILE_CMDS_DEPS
+ _DEPFILES_INCLUDED += $(dep)
+ $(eval includedep $(dep))
+endif
+
+# call the tool
+local cmds := $(TOOL_$(tool)_DTRACE_HDR_CMDS)
+local deps += $(TOOL_$(tool)_DTRACE_DEPEND) $(source)
+local orderdeps += $(TOOL_$(tool)_DTRACE_DEPORD) $(dirdep)
+
+# generate the rule.
+$(eval $(def_dtrace_hdr_rule))
+
+
+#
+# Adjust the object files and generate one from the D source, if needed.
+#
+ifn1of ($(bld_trg), $(TOOL_$(tool)_DTRACE_OBJ_NOT_NEEDED))
+ # Figure out all the props.
+ ifndef TOOL_$(tool)_DTRACE_OBJ_CMDS
+ $(error kBuild: TOOL_$(tool)_DTRACE_OBJ_CMDS isn't defined! target=$(target) source=$(source) )
+ endif
+ local outbase := $(dtracedir)/$(basename $(notdir $(source)))
+ local out := $(outbase)-dtrace-object-format.o
+ local tmp := $(kb-src-prop DTRACE_OBJ_FLAGS,flags,left-to-right,)
+ local tmp := $(kb-src-prop DEPS,deps,left-to-right,$(defpath))
+ local tmp := $(kb-src-prop ORDERDEPS,orderdeps,left-to-right,$(defpath))
+ local dirdep := $(call DIRDEP,$(dir $(out)))
+
+ # Adjust paths if we got a default path.
+ ifneq ($(defpath),)
+ local source := $(abspathex $(source),$(defpath))
+ endif
+
+ # dependency file.
+ local dep := $(out)$(SUFF_DEP)
+ ifndef NO_COMPILE_CMDS_DEPS
+ _DEPFILES_INCLUDED += $(dep)
+ $(eval includedep $(dep))
+ endif
+
+ # call the tool
+ local cmds := $(TOOL_$(tool)_DTRACE_OBJ_CMDS)
+ local deps += $(TOOL_$(tool)_DTRACE_DEPEND) $(source)
+ local orderdeps += $(TOOL_$(tool)_DTRACE_DEPORD) $(dirdep)
+
+ # generate the rule.
+ $(eval $(def_dtrace_obj_rule))
+endif
+
+endef # def_src_handler_dtrace
+
+
+
+#
+# The pre-target hook.
+#
+define def_unit_dtrace_target_pre
+
+local dtracedir := $($(target)_0_OUTDIR)/dtrace
+$(eval $(target)_INCS += $(dtracedir))
+
+endef #def_unit_dtrace_target_pre
+
diff --git a/kBuild/units/gccprecomp.kmk b/kBuild/units/gccprecomp.kmk
new file mode 100644
index 0000000..bf9a49c
--- /dev/null
+++ b/kBuild/units/gccprecomp.kmk
@@ -0,0 +1,67 @@
+# $Id: gccprecomp.kmk 3415 2020-08-20 23:43:33Z bird $
+## @file
+# kBuild Unit - Target Level Precompiled Headers for GNU GCC.
+#
+
+#
+# Copyright (c) 2016-2019 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+
+UNIT_gccprecomp = Target level precompiled Headers for Visual C++
+
+#
+# Early target processing pass #1.
+#
+# This sets $(target)_1_GCC_PCH_DIR as the include directory for the precompiled
+# header, adding it to BLDDIRS to get a mkdir rule for it, and then calculates the
+# .gch name and stores that in $(target)_1_GCC_PCH_FILE for compile rule dependencies.
+#
+define def_unit_gccprecomp_target_pre
+ $(target)_BLDDIRS += $($(target)_0_OUTDIR)/pch/
+ $(target)_1_GCC_PCH_DIR := $($(target)_0_OUTDIR)/pch/
+ $(target)_1_GCC_PCH_FILE := $($(target)_0_OUTDIR)/pch/$(notdir $($(target)_PCH_HDR)).gch
+endef
+
+#
+# Early target processing pass #2.
+#
+# This sets up a rule for creating the .gch file after qt5 and similar units
+# are done modifying INCS, DEFS and company. The 'tool' variable is defined by
+# footer-pass2-compiling-targets.kmk and is really the LD tool, but that'll
+# have to do for now. The '-PCH' variant of the GCC/LLVM tool, is defined together
+# with $(tool) and allow us to bypass the options and dependencies triggered
+# by _1_VCC_PCH_FILE, _1_VCC_COMMON_OBJ_PDB and _PCH_HDR, and also make sure we
+# don't get circular dependencies by way of kDepObj and the debug info.
+#
+define def_unit_gccprecomp_target_pre_2
+ local source := $($(target)_PCH_HDR)
+ local suff := $(suffix $(source))
+ local type := PCH
+ $(kb-src-one 4)
+endef
+
diff --git a/kBuild/units/lex.kmk b/kBuild/units/lex.kmk
new file mode 100644
index 0000000..d8ec238
--- /dev/null
+++ b/kBuild/units/lex.kmk
@@ -0,0 +1,153 @@
+# $Id: lex.kmk 3284 2019-01-05 01:40:31Z bird $
+## @file
+# lex unit.
+#
+
+#
+# Copyright (c) 2008-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+ifdef UNIT_lex
+ $(error kBuild: The lex unit was included twice!)
+endif
+UNIT_lex = lex
+
+# Add our target properties.
+PROPS_TOOLS += LEXTOOL
+PROPS_SINGLE += LEXTOOL
+PROPS_ACCUMULATE_R += LEXFLAGS
+
+# Add ourselves to the default source handlers.
+KBUILD_SRC_HANDLERS += \
+ .l:def_src_handler_lex
+
+
+## wrapper the compile command dependency check.
+ifndef NO_COMPILE_CMDS_DEPS
+ _DEP_LEX_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_LEX_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _DEP_LEX_CMDS =
+endif
+
+
+##
+# Generates the rules for running flex on a specific source file.
+#
+# @param $(obj) The object file.
+# @param lots more
+define def_lex_rule
+$(out) + $(output_extra) +| $(output_maybe) : \
+ $(deps) \
+ $(value _DEP_LEX_CMDS) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
+ $$(QUIET)$$(RM) -f -- $(dep) $(out) $(output_extra) $(output_maybe)
+
+$(cmds)
+
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_LEX_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_LEX_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+# update globals
+_OUT_FILES += $(out) $(output_extra) $(output_maybe)
+$(target)_GEN_SOURCES_ += $(out)
+$(target)_2_INTERMEDIATES += $(intermediates)
+
+endef # def_lex_rule
+
+##
+# Handler for .l files listed in the SOURCES properties.
+#
+# .l files are transformed into .c files that then gets compiled by
+# the C compiler.
+#
+# @param target The target file.
+# @param source The source file.
+# @param lots more
+# @returns quite a bit.
+define def_src_handler_lex
+# Figure out all the props.
+local type := LEX
+local tmp := $(kb-src-tool tool)
+ifeq ($(tool),)
+$(error kBuild: $(target) / $(sources) does not a (lex) tool defined!)
+endif
+ifndef TOOL_$(tool)_LEX_CMDS
+$(error kBuild: TOOL_$(tool)_LEX_CMDS isn't defined! target=$(target) source=$(source) )
+endif
+local out := $(kb-obj-base outbase).c
+local tmp := $(kb-src-prop LEXFLAGS,flags,left-to-right,)
+local tmp := $(kb-src-prop DEPS,deps,left-to-right,$(defpath))
+local tmp := $(kb-src-prop ORDERDEPS,orderdeps,left-to-right,$(defpath))
+ifdef TOOL_$(tool)_LEX_OUT_FILE # .c/.cpp output depends on flags.
+ local out := $(strip $(TOOL_$(tool)_LEX_OUT_FILE))
+ ifeq ($(out),)
+ local out := $(outbase).c
+ endif
+endif
+local dirdep := $(call DIRDEP,$(dir $(out)))
+
+# Adjust paths if we got a default path.
+ifneq ($(defpath),)
+ local source := $(abspathex $(source),$(defpath))
+endif
+
+# dependency file.
+local dep := $(out)$(SUFF_DEP)
+ifndef NO_COMPILE_CMDS_DEPS
+ _DEPFILES_INCLUDED += $(dep)
+ $(eval includedep $(dep))
+endif
+
+# call the tool
+local cmds := $(TOOL_$(tool)_LEX_CMDS)
+local output_extra := $(TOOL_$(tool)_LEX_OUTPUT)
+local output_maybe := $(TOOL_$(tool)_LEX_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_LEX_DEPEND) $(source)
+local orderdeps += $(TOOL_$(tool)_LEX_DEPORD) $(dirdep)
+
+# Whether it generates a header file depends on the tool / flags.
+local intermediates := $(filter %.h %.hpp %.h++ %.H,$(output_extra))
+
+# generate the rule.
+$(eval $(def_lex_rule))
+
+endef # def_src_handler_lex
+
+
diff --git a/kBuild/units/qt-Q_OBJECT.sed b/kBuild/units/qt-Q_OBJECT.sed
new file mode 100644
index 0000000..1ac1786
--- /dev/null
+++ b/kBuild/units/qt-Q_OBJECT.sed
@@ -0,0 +1,36 @@
+# $Id: qt-Q_OBJECT.sed 3558 2022-03-02 00:47:18Z bird $
+## @file
+# Qt unit - sed script for checking for Q_OBJECT in a file.
+#
+# This is not very sophisticated, but it helps avoid generating
+# files we don't need. It outputs '1' when Q_OBJECT is found
+# and then quits, allowing us to do $(if $(shell ...),moc_...).
+# is
+#
+
+#
+# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+
+/Q_OBJECT/!b skip
+s/^.*$/1/
+q 0
+:skip
+d
diff --git a/kBuild/units/qt3.kmk b/kBuild/units/qt3.kmk
new file mode 100644
index 0000000..809fd72
--- /dev/null
+++ b/kBuild/units/qt3.kmk
@@ -0,0 +1,947 @@
+# $Id: qt3.kmk 3418 2020-08-21 11:02:13Z bird $
+## @file
+# Qt 3.3.x unit.
+#
+
+#
+# Copyright (c) 2008-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+
+ifdef UNIT_qt3
+ $(error kBuild: The qt3 unit was included twice!)
+endif
+UNIT_qt3 = qt3
+
+
+if !defined(UNIT_qt4) && !defined(UNIT_qt5)
+ # Add our target properties (same as qt4 & qt5).
+ PROPS_SINGLE += QTTOOL MOCTOOL UICTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE QT_PREFIX
+ PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS LRCFLAGS QT_TRANSLATIONS QT_MOCSRCS QT_MOCHDRS
+endif
+PROPS_SINGLE +=
+PROPS_ACCUMULATE_R += QT_IMAGES
+
+
+#
+# The QT3 SDK.
+#
+# This is implemented here rather than in sdks/QT3.kmk to enforce the global USES.
+# It also makes things easier to develop, with fewer files I mean.
+#
+## @todo the SDK might actually not be necessary as it turns out... For now it servers
+# a purpose if the host differs from the target, in theory at least.
+SDK_QT3 = Qt3
+
+# SDK Specific Properties
+# PATH_SDK_QT3 - the general location of the Qt3 SDK stuff.
+# PATH_SDK_QT3_INC - the Qt3 include directory.
+# PATH_SDK_QT3_LIB - the Qt3 library directory for KBUILD_TARGET.
+# PATH_SDK_QT3_LIB.amd64 - the Qt3 library directory for AMD64.
+# PATH_SDK_QT3_LIB.x86 - the Qt3 library directory for X86.
+ifndef PATH_SDK_QT3
+ PATH_SDK_QT3 := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v3*)))
+ ifeq ($(PATH_SDK_QT3),)
+ # If target == host, try look for Qt in the various platform specific places.
+ ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
+ ifeq ($(KBUILD_TARGET),darwin)
+ # No idea here yet...
+ else ifeq ($(KBUILD_TARGET),os2)
+ # No idea here yet... Check QTDIR perhaps, but for now users have toset PATH_SDK_QT3.
+ else ifeq ($(KBUILD_TARGET),win)
+ # No idea here yet... Check QTDIR perhaps, but for now users have toset PATH_SDK_QT3.
+ else
+ # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT3_LIB* stuff if it doesn't work.
+ # Try find the general location of the thing by looking for the qm2ts program, then try looking for
+ # the moc program in likely and unlikely places save /usr[/local]/bin to avoid mistaking it with Qt4.
+ PATH_SDK_QT3 := $(patsubst %/bin/qm2ts,%,$(firstword $(wildcard \
+ /usr/lib/qt-3.3/bin/qm2ts \
+ /usr/lib64/qt-3.3/bin/qm2ts \
+ /usr/qt/3/bin/qm2ts \
+ $(if $(QTDIR),$(QTDIR)/bin/qm2ts) \
+ /usr/bin/qm2ts \
+ /usr/local/bin/qm2ts \
+ /usr/share/qt3/bin/qm2ts \
+ )))
+ ifeq ($(PATH_SDK_QT3),) # Try with moc, but not in /usr/bin and /usr/local/bin.
+ PATH_SDK_QT3 := $(patsubst %/bin/moc,%,$(firstword $(wildcard \
+ /usr/lib/qt-3.3/bin/moc \
+ /usr/lib64/qt-3.3/bin/moc \
+ /usr/qt/3/bin/moc \
+ /usr/share/qt3/bin/moc \
+ $(if $(QTDIR),$(QTDIR)/bin/moc) \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT3),)
+ # Found something! Export the variable for the benefit of recursive make instances.
+ export PATH_SDK_QT3
+
+ # Determin the include directory.
+ ifeq ($(PATH_SDK_QT3_INC),)
+ 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)))
+ ifneq ($(PATH_SDK_QT3_INC),)
+ export PATH_SDK_QT3_INC
+ endif
+ endif
+
+ # Determin the most likely x86 and AMD64 lib directories (only used for making PATH_SDK_QT3_LIB).
+ ifeq ($(PATH_SDK_QT3_LIB.x86),)
+ PATH_SDK_QT3_LIB.x86 := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT3)/lib32/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib32/qt3/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib32/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ /usr/lib32/libqt-mt$(SUFF_DLL) \
+ /usr/lib32/qt3/libqt-mt$(SUFF_DLL) \
+ /usr/lib/i386-linux-gnu/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib32/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib32/qt3/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib32/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib/i386-linux-gnu/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/i386-linux-gnu/libqt-mt$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT3_LIB.x86),)
+ export PATH_SDK_QT3_LIB.x86
+ endif
+ endif
+ ifeq ($(PATH_SDK_QT3_LIB.amd64),)
+ PATH_SDK_QT3_LIB.amd64 := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT3)/lib64/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib64/qt3/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib64/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/amd64/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/64/libqt-mt$(SUFF_DLL) \
+ /usr/lib64/libqt-mt$(SUFF_DLL) \
+ /usr/lib64/qt3/libqt-mt$(SUFF_DLL) \
+ /usr/lib64/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ /usr/lib/amd64/libqt-mt$(SUFF_DLL) \
+ /usr/lib/64/libqt-mt$(SUFF_DLL) \
+ /usr/lib/x86_64-linux-gnu/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib64/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib64/qt3/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib64/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib/amd64/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib/64/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib/x86_64-linux-gnu/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/x86_64-linux-gnu/libqt-mt$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT3_LIB.amd64),)
+ export PATH_SDK_QT3_LIB.amd64
+ endif
+ endif
+
+ # Determin the KBUILD_TARGET lib directory.
+ ifeq ($(PATH_SDK_QT3_LIB),)
+ PATH_SDK_QT3_LIB := $(PATH_SDK_QT3_LIB.$(KBUILD_TARGET_ARCH))
+ ifeq ($(PATH_SDK_QT3_LIB),)
+ PATH_SDK_QT3_LIB := $(patsubst %/libqt-mt$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT3)/lib/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/qt3/libqt-mt$(SUFF_DLL) \
+ $(PATH_SDK_QT3)/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ /usr/lib/libqt-mt$(SUFF_DLL) \
+ /usr/lib/qt3/libqt-mt$(SUFF_DLL) \
+ /usr/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib/qt3/libqt-mt$(SUFF_DLL) \
+ /usr/local/lib/qt3-3/lib/libqt-mt$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT3_LIB),)
+ export PATH_SDK_QT3_LIB
+ endif
+ endif
+ endif
+
+ endif
+ endif # Unices
+ endif
+ # Found it?
+ ifeq ($(PATH_SDK_QT3),)
+ $(warning kBuild: Couldn't find the Qt3 headers and libaries...)
+ PATH_SDK_QT3 := $(KBUILD_DEVTOOLS_TRG)/qt/not-found
+ endif
+ endif
+else
+ # Resolve any fancy stuff once and for all.
+ PATH_SDK_QT3 := $(PATH_SDK_QT3)
+endif
+
+# Libraries can be in either Frameworks or lib depending on how you
+# build it on the mac. The .dmg installs into Frameworks but builds into lib.
+PATH_SDK_QT3_LIB ?= $(PATH_SDK_QT3)/lib
+PATH_SDK_QT3_INC ?= $(PATH_SDK_QT3)/include
+
+# The bits that kBuild picks up.
+# (nothing here)
+
+
+#
+# The QT3 tool.
+#
+# This is implemented here rather than in tools/QT3.kmk to enforce the global USES.
+# It also makes things easier to develop, with fewer files I mean.
+#
+TOOL_QT3 = Qt3
+
+# Tool Specific Properties (PATH_TOOL_QT3_BIN and TOOL_QT3_BIN_SUFF)
+# TOOL_QT3_BIN_SUFF - the '-qt3' bit found on debian.
+# PATH_TOOL_QT3_BIN - the directory containing moc, uic, lrelease, lupdate and qm2ts.
+ifndef PATH_TOOL_QT3_BIN
+ PATH_TOOL_QT3_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_BLD)/qt/v3*/bin)))
+ ifeq ($(PATH_TOOL_QT3_BIN),)
+ if1of ($(KBUILD_HOST), win os2)
+ # Sorry, no joy here. Check QTDIR perhaps, but for now users have to set PATH_TOOL_QT3_BIN.
+ else
+ ifdef TOOL_QT3_BIN_SUFF
+ TOOL_QT3_BIN_SUFF := $(TOOL_QT3_BIN_SUFF)
+ endif
+ PATH_TOOL_QT3_BIN := $(patsubst %/qm2ts$(TOOL_QT3_BIN_SUFF),%,$(firstword $(wildcard \
+ /usr/lib/qt-3.3/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
+ /usr/lib64/qt-3.3/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
+ /usr/qt/3/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
+ $(if $(QTDIR),$(QTDIR)/bin/qm2ts$(TOOL_QT3_BIN_SUFF)) \
+ /usr/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
+ /usr/local/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
+ /usr/share/qt3/bin/qm2ts$(TOOL_QT3_BIN_SUFF) \
+ )))
+ ifeq ($(PATH_TOOL_QT3_BIN),)
+ # If we couldn't find the qt3 specific tool qm2ts, debian and other skip
+ # this (thanks a bundle). Try with look for 'moc' with a '-qt3' extension,
+ # then for just moc. In the latter case don't search /usr[/local]/bin to
+ # void finding the qt4 tools and messing up.
+ ifeq ($(TOOL_QT3_BIN_SUFF),)
+ PATH_TOOL_QT3_BIN := $(patsubst %/moc-qt3,%,$(firstword $(wildcard \
+ /usr/bin/moc-qt3 \
+ /usr/local/bin/moc-qt3 \
+ /usr/lib/qt-3.3/bin/moc-qt3 \
+ /usr/lib64/qt-3.3/bin/moc-qt3 \
+ /usr/qt/3/bin/moc-qt3 \
+ /usr/share/qt3/bin/moc-qt3 \
+ $(if $(QTDIR),$(QTDIR)/bin/moc-qt3) \
+ )))
+ endif
+ ifneq ($(PATH_TOOL_QT3_BIN),)
+ export TOOL_QT3_BIN_SUFF := -qt3
+ else
+ PATH_TOOL_QT3_BIN := $(patsubst %/moc$(TOOL_QT3_BIN_SUFF),%,$(firstword $(wildcard \
+ /usr/lib/qt-3.3/bin/moc$(TOOL_QT3_BIN_SUFF) \
+ /usr/lib64/qt-3.3/bin/moc$(TOOL_QT3_BIN_SUFF) \
+ /usr/qt/3/bin/moc$(TOOL_QT3_BIN_SUFF) \
+ /usr/share/qt3/bin/moc$(TOOL_QT3_BIN_SUFF) \
+ $(if $(QTDIR),$(QTDIR)/bin/moc$(TOOL_QT3_BIN_SUFF)) \
+ )))
+ endif
+ endif
+ ifneq ($(PATH_TOOL_QT3_BIN),)
+ export PATH_TOOL_QT3_BIN
+ endif
+ endif
+ endif
+ # If not found, we'll enter the 'pathless' mode.
+else
+ # Resolve any fancy stuff once and for all.
+ PATH_TOOL_QT3_BIN := $(PATH_TOOL_QT3_BIN)
+ TOOL_QT3_BIN_SUFF := $(TOOL_QT3_BIN_SUFF)
+endif
+ifneq ($(PATH_TOOL_QT3_BIN),)
+ ifeq ($(KBUILD_HOST),os2)
+ TOOL_QT3_ENV_SETUP ?= $(REDIRECT) -E 'BEGINLIBPATH=$(PATH_TOOL_QT3_BIN);$(libpath BEGINLIBPATH)' --
+ endif
+ TOOL_QT3_MOC ?= $(TOOL_QT3_ENV_SETUP) $(PATH_TOOL_QT3_BIN)/moc$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT3_UIC ?= $(TOOL_QT3_ENV_SETUP) $(PATH_TOOL_QT3_BIN)/uic$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT3_LRC ?= $(TOOL_QT3_ENV_SETUP) $(PATH_TOOL_QT3_BIN)/lrelease$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT3_LUPDATE ?= $(TOOL_QT3_ENV_SETUP) $(PATH_TOOL_QT3_BIN)/lupdate$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
+else
+ # Pathless, relies on the environment.
+ TOOL_QT3_MOC ?= moc$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT3_UIC ?= uic$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT3_LRC ?= lrelease$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT3_LUPDATE ?= lupdate$(TOOL_QT3_BIN_SUFF)$(HOST_SUFF_EXE)
+endif
+
+# General Properties used by kBuild and/or units/qt.kmk
+TOOL_QT3_MOCFLAGS ?=
+TOOL_QT3_UICFLAGS ?=
+TOOL_QT3_LRCFLAGS ?=
+
+
+## MOC a C++ source file.
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT3_MOC_CPP_DEPEND =
+TOOL_QT3_MOC_CPP_DEPORD =
+TOOL_QT3_MOC_CPP_OUTPUT =
+TOOL_QT3_MOC_CPP_OUTPUT_MAYBE =
+define TOOL_QT3_MOC_CPP_CMDS
+ $(QUIET)$(TOOL_QT3_MOC)\
+ $(flags)\
+ -o $(out)\
+ -i \
+ $(source)
+endef
+
+## MOC a C++ header file.
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT3_MOC_HPP_DEPEND =
+TOOL_QT3_MOC_HPP_DEPORD =
+TOOL_QT3_MOC_HPP_OUTPUT =
+TOOL_QT3_MOC_HPP_OUTPUT_MAYBE =
+define TOOL_QT3_MOC_HPP_CMDS
+ $(QUIET)$(TOOL_QT3_MOC)\
+ $(flags)\
+ -o $(out)\
+ $(source)
+endef
+
+## Compile a Qt user interface file (.ui).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out.cpp) The C++ source file to be generated.
+# @param $(out.h) The C++ header file to be generated.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT3_UIC_UI_DEPEND =
+TOOL_QT3_UIC_UI_DEPORD =
+TOOL_QT3_UIC_UI_OUTPUT =
+TOOL_QT3_UIC_UI_OUTPUT_MAYBE =
+define TOOL_QT3_UIC_UI_CMDS
+ $(QUIET)$(TOOL_QT3_UIC)\
+ $(flags)\
+ -o $(out.h)\
+ $(source)
+ $(QUIET)$(TOOL_QT3_UIC)\
+ $(flags)\
+ -i $(out.h) \
+ -o $(out.cpp)\
+ $(source)
+endef
+
+## Compile a Qt translation file (.ts).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT3_LRC_TS_DEPEND =
+TOOL_QT3_LRC_TS_DEPORD =
+TOOL_QT3_LRC_TS_OUTPUT =
+TOOL_QT3_LRC_TS_OUTPUT_MAYBE =
+define TOOL_QT3_LRC_TS_CMDS
+ $(QUIET)$(TOOL_QT3_LRC)\
+ $(flags)\
+ $(source)\
+ -qm $(out)
+endef
+
+
+
+#
+#
+# Back to the Qt3 unit.
+#
+#
+
+
+## wrapper for the lrelease (LRC) command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT3_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT3_LRC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt3_target_pre_handle_translation helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt3_target_pre_handle_translation_dx
+
+$(out) + $(more_output) +| $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT3_LRC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_LRC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
+$(target)-inst-nls_SOURCES += $(out)
+
+endef # def_unit_qt3_target_pre_handle_translation_dx
+
+##
+# Handle a source file listed in QT_TRANSLATIONS.
+#
+# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
+# to be translated into .qm files that are loadble by Qt.
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt3_target_pre_handle_translation
+local type := LRC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
+local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
+local out := $(outbase).qm
+local dep := $(out).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_LRC_TS_CMDS
+ $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
+local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
+local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt3_target_pre_handle_translation_dx))
+
+endef # def_unit_qt3_target_pre_handle_translation
+
+
+
+## wrapper for the UIC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT3_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_UIC_CMDS_PREV_),$$(commands $(out.h)),FORCE)
+else
+ _UNIT_QT3_UIC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt3_src_handler_ui helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt3_target_pre_handle_ui_dx
+
+$(out.h) + $(out.cpp) +| $(realout.h) $(realout.cpp) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT3_UIC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,uic,$(target),$(source),$(out.h) $(out.cpp))
+ $(QUIET2)$(RM) -f $(out.h) $(out.cpp) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out.h) $(realout.h)
+ $(QUIET)$(CP) --changed -f $(out.cpp) $(realout.cpp)
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_UIC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out.h)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_2_INTERMEDIATES += $(realout.h)
+$(target)_GEN_SOURCES_ += $(realout.cpp)
+$(target)_CLEAN += $(out.h) $(out.cpp) $(realout.h) $(realout.cpp) $(more_output) $(maybe_output) $(dep)
+
+endef # def_unit_qt3_target_pre_handle_ui_dx
+
+##
+# Source handler for .ui sources.
+#
+# @remarks $(evalvalctx me).
+define def_unit_qt3_src_handler_ui
+local type := UIC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtuicdir := $($(target)_0_OUTDIR)/qtuic
+local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
+local out.h := $(outbase).tmp.h
+local out.cpp := $(outbase).tmp.cpp
+local realout.h := $(outbase).h
+local realout.cpp:=$(outbase).cpp
+local dep := $(realout.h).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_UIC_UI_CMDS
+ $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
+local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
+local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt3_target_pre_handle_ui_dx))
+
+endef # def_unit_qt3_src_handler_ui
+
+
+
+## wrapper for the MOC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT3_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT3_MOC_HPP_CMDS_DEP =
+endif
+
+##
+# def_unit_qt3_target_pre_handle_moc_hdr helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt3_target_pre_handle_moc_hdr_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT3_MOC_HPP_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,moc,$(target),$(source),$(realout))
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_MOC_HPP_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_GEN_SOURCES_ += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef
+
+##
+# Handle a source file listed in QT_MOCHDRS.
+#
+# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
+# generate a .cpp file for each of them and add it to the generated
+# sources so that it's compiled and linked. (There is an alternative
+# way to do this where the .cpp file is included, this isn't currently
+# supported by this unit.)
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt3_target_pre_handle_moc_hdr
+local type := MOC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.cpp
+local realout := $(outbase).cpp
+local dep := $(realout).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_MOC_HPP_CMDS
+ $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
+local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
+local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt3_target_pre_handle_moc_hdr_dx))
+
+endef # def_unit_qt3_target_pre_handle_moc_hdr
+
+
+
+## wrapper for the MOC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT3_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT3_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT3_MOC_CPP_CMDS_DEP =
+endif
+
+##
+# def_unit_qt3_target_pre_handle_moc_src helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt3_target_pre_handle_moc_src_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT3_MOC_CPP_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,moc,$(target),$(source),$(realout))
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT3_MOC_CPP_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef
+
+##
+# Handle a source file listed in QT_MOCSRCS.
+#
+# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
+# a .moc file that we're expected to generate here.
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt3_target_pre_handle_moc_src
+local type := MOC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.moc
+local realout := $(outbase).moc
+local dep := $(realout).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_MOC_CPP_CMDS
+ $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
+local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
+local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt3_target_pre_handle_moc_src_dx))
+
+endef # def_unit_qt3_target_pre_handle_moc_src
+
+
+##
+# Adds sources containing Q_OBJECT to QT_MOCSRCS.
+define def_unit_qt3_target_pre_cpp_source
+ifneq ($(file-size $(source)),-1)
+ ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
+ $(eval $(target)_QT_MOCSRCS += $(source))
+ endif
+endif
+endef # def_unit_qt3_target_pre_cpp_source
+
+
+##
+# Invoked early in the processing of a target that uses the Qt unit.
+#
+# It will append the qt source handlers to the target (.h, .ui, .ts,
+# .png, .bmp, .gif).
+#
+# It will then check all the C++ sources and check which needs
+# a .moc files and generate rules and dependencies fofor these
+#
+define def_unit_qt3_target_pre
+
+# Make QTTOOL the default for the specific Qt tools instead of TOOL.
+ifneq ($($(target)_QTTOOL),)
+ ifeq ($($(target)_MOCTOOL),)
+ $(target)_MOCTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_UICTOOL),)
+ $(target)_UICTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_LRCTOOL),)
+ $(target)_LRCTOOL := $($(target)_QTTOOL)
+ endif
+endif
+
+# Deal with QT_MODULES and QT_PREFIX.
+local qt_prefix := $(firstword \
+ $($(target)_QT_PREFIX.$(bld_trg)) \
+ $($(target)_QT_PREFIX.$(bld_trg_arch)) \
+ $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
+ $($(target)_QT_PREFIX.$(bld_type)) \
+ $($(target)_QT_PREFIX))
+ifeq ($(bld_trg),win)
+ local qt_lib := $(firstword $(wildcard \
+ $(PATH_SDK_QT3_LIB)/dynamic/$(qt_prefix)qt-mt3*$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/$(qt_prefix)qt-mt3*$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/dynamic/$(qt_prefix)qt-mt$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/$(qt_prefix)qt-mt$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/dynamic/$(qt_prefix)Qt3*$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/$(qt_prefix)Qt3*$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/dynamic/$(qt_prefix)Qt*$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/$(qt_prefix)Qt*$(SUFF_LIB) \
+ ) $(PATH_SDK_QT3_LIB)/$(qt_prefix)qt-mt$(SUFF_LIB) )
+ $(eval $(target)_LIBS += $(qt_lib) )
+ ifeq ($(tool_do),LINK_PROGRAM)
+ local qt_main_lib := $(firstword $(wildcard \
+ $(PATH_SDK_QT3_LIB)/$(qt_prefix)qtmain$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/qtmain$(SUFF_LIB) \
+ ) $(PATH_SDK_QT3_LIB)/$(qt_prefix)qtmain$(SUFF_LIB) )
+ $(eval $(target)_LIBS += $(qt_main_lib) )
+ endif
+else ifeq ($(bld_trg),os2)
+ # This is a real PITA since the dll/lib can be called (almost) anything. :-(
+ local qt_lib := $(firstword $(wildcard \
+ $(PATH_SDK_QT3_LIB)/$(qt_prefix)*qt3*$(SUFF_LIB) \
+ $(PATH_SDK_QT3_LIB)/$(qt_prefix)*qt*$(SUFF_LIB) \
+ ))
+ ifeq ($(qt_lib),)
+ local qt_prls := $(basename $(wildcard $(PATH_SDK_QT3_LIB)/$(qt_prefix)*.prl))
+ local qt_defs := $(basename $(wildcard $(PATH_SDK_QT3_LIB)/$(qt_prefix)*.def))
+ local qt_dlls := $(basename $(wildcard $(PATH_SDK_QT3_LIB)/$(qt_prefix)*.dll))
+ local qt_libs := $(basename $(wildcard $(PATH_SDK_QT3_LIB)/$(qt_prefix)*.lib))
+ local qt_lib := $(firstword \
+ $(addsuffix .lib,$(filter $(qt_prls), $(filter $(qt_defs), $(filter $(qt_dlls), $(qt_libs))))) \
+ $(PATH_SDK_QT3_LIB)/myqt.lib )
+ endif
+ $(eval $(target)_LIBS += $(qt_lib) )
+else
+ local qt_lib := $(PATH_SDK_QT3_LIB)/lib$(qt_prefix)qt-mt$(SUFF_DLL)
+ $(eval $(target)_LIBS += $(qt_lib) )
+endif
+$(eval $(target)_INCS += $(PATH_SDK_QT3_INC) )
+
+# On Qt3 we will try pickup the QMAKE_PRL_DEFINES listed in the .prl file (in libs).
+local qt_prl := $(firstword $(wildcard \
+ $(patsubst %$(SUFF_DLL),%,$(patsubst %$(SUFF_LIB),%,$(qt_lib))).prl \
+ $(dir $(qt_lib))/$(qt_prefix)qt-mt.prl \
+ $(dir $(qt_lib))/*qt-mt*.prl \
+ $(dir $(qt_lib))/*qt*.prl \
+ ))
+ifneq ($(qt_prl),)
+ include $(qt_prl)
+ $(eval $(target)_DEFS += $(QMAKE_PRL_DEFINES))
+endif
+
+# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
+# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
+ifndef $(target)_QT_MOCSRCS
+ $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
+ $($(target)_SOURCES.$(bld_trg)) \
+ $($(target)_SOURCES.$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg_cpu)) \
+ $($(target)_SOURCES.$(bld_type)) \
+ $($(target)_SOURCES) \
+ ), $(evalval def_unit_qt3_target_pre_cpp_source))
+endif
+
+# Install source handlers for .ui files.
+$(target)_SRC_HANDLERS += \
+ .ui:def_unit_qt3_src_handler_ui \
+ .UI:def_unit_qt3_src_handler_ui
+
+# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
+local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
+local qtuicdir := $($(target)_0_OUTDIR)/qtuic
+local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
+$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtnlsdir) )
+$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir) )
+
+# Calc .ui sources so we can add them to the QT_MOCSRCS and QT_MOCHDRS.
+local ui_sources := $(notdir $(basename $(filter %.ui %.UI, \
+ $($(target)_SOURCES.$(bld_trg)) \
+ $($(target)_SOURCES.$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg_cpu)) \
+ $($(target)_SOURCES.$(bld_type)) \
+ $($(target)_SOURCES) \
+ )))
+#$(error ui_sources:=$(ui_sources))
+
+# Deal with QT_MOCSRCS.
+$(foreach source, \
+ $($(target)_QT_MOCSRCS.$(bld_trg)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
+ $($(target)_QT_MOCSRCS.$(bld_type)) \
+ $($(target)_QT_MOCSRCS) \
+ $(addsuffix .h,$(addprefix $(qtuicdir)/,$(notdir $(basename $(ui_sources))))) \
+ , $(evalvalctx def_unit_qt3_target_pre_handle_moc_src))
+
+# Deal with QT_MOCHDRS.
+$(foreach source, \
+ $($(target)_QT_MOCHDRS.$(bld_trg)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
+ $($(target)_QT_MOCHDRS.$(bld_type)) \
+ $($(target)_QT_MOCHDRS) \
+ $(addsuffix .h,$(addprefix $(qtuicdir)/,$(notdir $(basename $(ui_sources))))) \
+ , $(evalvalctx def_unit_qt3_target_pre_handle_moc_hdr))
+
+# Deal with QT_TRANSLATIONS.
+# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
+local translations := \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_type)) \
+ $($(target)_QT_TRANSLATIONS)
+ifneq ($(strip $(translations)),)
+ local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
+ $(eval $(expr))
+ ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
+ $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
+ else
+ $(target)-inst-nls_MODE := 0644
+ endif
+ ifdef $(target)_QT_TRANSLATIONS_INST
+ $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
+ endif
+ $(target)-inst-nls_SOURCES :=
+ $(foreach source, $(translations)\
+ , $(evalvalctx def_unit_qt3_target_pre_handle_translation))
+endif
+
+endef # def_unit_qt3_target_pre
+
+
+#
+# Rule for debugging.
+#
+unit-qt3-show-vars:
+ @$(ECHO) 'The Qt3 SDK variables:'
+ @$(ECHO) ' PATH_SDK_QT3 = "$(PATH_SDK_QT3)"'
+ @$(ECHO) ' PATH_SDK_QT3_INC = "$(PATH_SDK_QT3_INC)"'
+ @$(ECHO) ' PATH_SDK_QT3_LIB = "$(PATH_SDK_QT3_LIB)"'
+ @$(ECHO) ' PATH_SDK_QT3_LIB.amd64 = "$(PATH_SDK_QT3_LIB.amd64)"'
+ @$(ECHO) ' PATH_SDK_QT3_LIB.x86 = "$(PATH_SDK_QT3_LIB.x86)"'
+ @$(ECHO) 'The Qt3 TOOL variables:'
+ @$(ECHO) ' PATH_TOOL_QT3_BIN = "$(PATH_TOOL_QT3_BIN)"'
+ @$(ECHO) ' TOOL_QT3_BIN_SUFF = "$(TOOL_QT3_BIN_SUFF)"'
+ @$(ECHO) ' TOOL_QT3_MOC = "$(TOOL_QT3_MOC)"'
+ @$(ECHO) ' TOOL_QT3_UIC = "$(TOOL_QT3_UIC)"'
+ @$(ECHO) ' TOOL_QT3_LRC = "$(TOOL_QT3_LRC)"'
+ @$(ECHO) ' TOOL_QT3_LUPDATE = "$(TOOL_QT3_LUPDATE)"'
+
diff --git a/kBuild/units/qt4.kmk b/kBuild/units/qt4.kmk
new file mode 100644
index 0000000..c92fcf4
--- /dev/null
+++ b/kBuild/units/qt4.kmk
@@ -0,0 +1,1107 @@
+# $Id: qt4.kmk 3284 2019-01-05 01:40:31Z bird $
+## @file
+# Qt 4 unit.
+#
+
+#
+# Copyright (c) 2008-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+
+ifdef UNIT_qt4
+ $(error kBuild: The qt4 unit was included twice!)
+endif
+UNIT_qt4 = qt4
+
+
+if !defined(UNIT_qt3) && !defined(UNIT_qt5)
+ # Add our target properties (same as qt3 & qt5).
+ PROPS_SINGLE += QTTOOL MOCTOOL UICTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE QT_PREFIX
+ PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS LRCFLAGS QT_TRANSLATIONS QT_MOCSRCS QT_MOCHDRS
+endif
+PROPS_SINGLE += RCCTOOL QT_INFIX
+PROPS_ACCUMULATE_R += RCCFLAGS QT_MODULES
+
+
+## @todo use pkg-config?
+
+#
+# The QT4 SDK.
+#
+# This is implemented here rather than in sdks/QT4.kmk to enforce the global USES.
+# It also makes things easier to develop, with fewer files I mean.
+#
+## @todo the SDK might actually not be necessary as it turns out... For now it servers
+# a purpose if the host differs from the target, in theory at least.
+SDK_QT4 = Qt4
+
+# SDK Specific Properties
+# PATH_SDK_QT4 - The general Qt4 root directory.
+# PATH_SDK_QT4_INC - The include directory.
+# PATH_SDK_QT4_LIB.amd64 - The lib directory for AMD64.
+# PATH_SDK_QT4_LIB.x86 - The lib directory for X86.
+# PATH_SDK_QT4_LIB - The lib directory for KBUILD_TARGET.
+ifndef PATH_SDK_QT4
+ PATH_SDK_QT4 := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v4*)))
+ ifeq ($(PATH_SDK_QT4),)
+ # If target == host, try look for Qt in the various platform specific places.
+ ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
+ ifeq ($(KBUILD_TARGET),darwin)
+ PATH_SDK_QT4 := $(patsubst %/Frameworks/QtCore.framework/Versions/4,%,$(firstword $(wildcard /Library/Frameworks/QtCore.framework/Versions/4)))
+ else ifeq ($(KBUILD_TARGET),win)
+ # No idea here yet...
+ else ifeq ($(KBUILD_TARGET),ose)
+ # No port...
+ else
+ # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT4_LIB* stuff if it doesn't work.
+ # Try find the general root of thing by looking for the qt3to4 program, if not found, then look for rcc.
+ PATH_SDK_QT4 := $(patsubst %/bin/qt3to4-qt4,%,$(firstword $(wildcard \
+ /usr/bin/qt3to4-qt4 \
+ /usr/local/bin/qt3to4-qt4 \
+ /usr/qt/4/bin/qt3to4-qt4 \
+ /usr/share/qt4/bin/qt3to4-qt4 \
+ )))
+ ifeq ($(PATH_SDK_QT4),)
+ PATH_SDK_QT4 := $(patsubst %/bin/qt3to4,%,$(firstword $(wildcard \
+ /usr/bin/qt3to4 \
+ /usr/local/bin/qt3to4 \
+ /usr/qt/4/bin/qt3to4 \
+ /usr/share/qt4/bin/qt3to4 \
+ )))
+ endif
+ ifeq ($(PATH_SDK_QT4),)
+ PATH_SDK_QT4 := $(patsubst %/bin/rcc-qt4,%,$(firstword $(wildcard \
+ /usr/bin/rcc-qt4 \
+ /usr/local/bin/rcc-qt4 \
+ /usr/qt/4/bin/rcc-qt4 \
+ /usr/share/qt4/bin/rcc-qt4 \
+ )))
+ endif
+ ifeq ($(PATH_SDK_QT4),)
+ PATH_SDK_QT4 := $(patsubst %/bin/rcc,%,$(firstword $(wildcard \
+ /usr/lib/*/qt4/bin/rcc \
+ /usr/bin/rcc \
+ /usr/local/bin/rcc \
+ /usr/qt/4/bin/rcc \
+ /usr/share/qt4/bin/rcc \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT4),)
+ export PATH_SDK_QT4
+
+ # Locate the include files.
+ ifeq ($(PATH_SDK_QT4_INC),)
+ PATH_SDK_QT4_INC := $(patsubst %/QtCore/qglobal.h,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt4/QtCore/qglobal.h) \
+ $(PATH_SDK_QT4)/include/QtCore/qglobal.h \
+ $(PATH_SDK_QT4)/include/qt4/QtCore/qglobal.h \
+ /usr/include/qt4/QtCore/qtglobal.h \
+ /usr/local/include/qt4/QtCore/qtglobal.h \
+ )))
+ ifneq ($(PATH_SDK_QT4_INC),)
+ export PATH_SDK_QT4_INC
+ endif
+ endif
+
+ # Now for the libraries (mostly for helping out finding the KBUILD_TARGET libs).
+ ifeq ($(PATH_SDK_QT4_LIB.x86),)
+ PATH_SDK_QT4_LIB.x86 := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT4)/lib32/libQtCore$(SUFF_DLL) \
+ $(PATH_SDK_QT4)/lib32/qt4/libQtCore$(SUFF_DLL) \
+ /usr/lib32/libQtCore$(SUFF_DLL) \
+ /usr/lib32/qt4/libQtCore$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
+ /usr/local/lib32/libQtCore$(SUFF_DLL) \
+ /usr/local/lib32/qt4/libQtCore$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
+ $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
+ $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
+ $(PATH_SDK_QT4)/lib/i386-linux-gnu/libQtCore$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT4_LIB.x86),)
+ export PATH_SDK_QT4_LIB.x86
+ endif
+ endif
+ ifeq ($(PATH_SDK_QT4_LIB.amd64),)
+ PATH_SDK_QT4_LIB.amd64 := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT4)/lib64/libQtCore$(SUFF_DLL) \
+ $(PATH_SDK_QT4)/lib64/qt4/libQtCore$(SUFF_DLL) \
+ $(PATH_SDK_QT4)/lib/amd64/libQtCore$(SUFF_DLL) \
+ /usr/lib64/libQtCore$(SUFF_DLL) \
+ /usr/lib64/qt4/libQtCore$(SUFF_DLL) \
+ /usr/lib/amd64/libQtCore$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
+ /usr/local/lib64/libQtCore$(SUFF_DLL) \
+ /usr/local/lib64/qt4/libQtCore$(SUFF_DLL) \
+ /usr/local/lib/amd64/libQtCore$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
+ $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
+ $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
+ $(PATH_SDK_QT4)/lib/x86_64-linux-gnu/libQtCore$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT4_LIB.amd64),)
+ export PATH_SDK_QT4_LIB.amd64
+ endif
+ endif
+
+ # And finally, the library path for KBUILD_TARGET.
+ ifeq ($(PATH_SDK_QT4_LIB),)
+ PATH_SDK_QT4_LIB := $(PATH_SDK_QT4_LIB.$(KBUILD_TARGET_ARCH))
+ ifeq ($(PATH_SDK_QT4_LIB),)
+ PATH_SDK_QT4_LIB := $(patsubst %/libQtCore$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT4)/lib/libQtCore$(SUFF_DLL) \
+ $(PATH_SDK_QT4)/lib/qt4/libQtCore$(SUFF_DLL) \
+ /usr/lib/libQtCore$(SUFF_DLL) \
+ /usr/lib/qt4/libQtCore$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/lib/$(type)/libQtCore$(SUFF_DLL)) \
+ /usr/local/lib/libQtCore$(SUFF_DLL) \
+ /usr/local/lib/qt4/libQtCore$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/local/lib/$(type)/libQtCore$(SUFF_DLL)) \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT4_LIB),)
+ export PATH_SDK_QT4_LIB
+ endif
+ endif
+
+ endif
+ endif # Unices
+ endif
+ # Found it?
+ ifeq ($(PATH_SDK_QT4),)
+ $(warning kBuild: Couldn't find the Qt4 headers and libaries...)
+ PATH_SDK_QT4 := $(KBUILD_DEVTOOLS_TRG)/qt/not-found
+ endif
+ endif
+else
+ # Resolve any fancy stuff once and for all.
+ PATH_SDK_QT4 := $(PATH_SDK_QT4)
+endif
+
+# Libraries can be in either Frameworks or lib depending on how you
+# build it on the mac. The .dmg installs into Frameworks but builds into lib.
+ifeq ($(KBUILD_TARGET),darwin)
+ ifndef PATH_SDK_QT4_LIB
+ ifneq ($(wildcard $(PATH_SDK_QT4)/Frameworks),)
+ PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/Frameworks
+ else
+ PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/lib
+ endif
+ endif
+else
+ PATH_SDK_QT4_LIB ?= $(PATH_SDK_QT4)/lib
+ PATH_SDK_QT4_INC ?= $(PATH_SDK_QT4)/include
+endif
+
+# The bits that kBuild picks up.
+# (nothing here)
+
+
+#
+# The QT4 tool.
+#
+# This is implemented here rather than in tools/QT4.kmk to enforce the global USES.
+# It also makes things easier to develop, with fewer files I mean.
+#
+TOOL_QT4 = Qt4
+
+# Tool Specific Properties
+# PATH_TOOL_QT4 - Obsolete.
+# PATH_TOOL_QT4_BIN - The
+# TOOL_QT4_BIN_SUFF -
+if !defined(PATH_TOOL_QT4_BIN) && defined(PATH_TOOL_QT4)
+ PATH_TOOL_QT4_BIN := $(PATH_TOOL_QT4)/bin
+endif
+ifndef PATH_TOOL_QT4_BIN
+ PATH_TOOL_QT4_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST)/qt/v4*/bin)))
+ if "$(PATH_TOOL_QT4_BIN)" == "" && "$(KBUILD_DEVTOOLS_HST_ALT)" != ""
+ PATH_TOOL_QT4_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST_ALT)/qt/v4*/bin)))
+ endif
+ ifeq ($(PATH_TOOL_QT4_BIN),)
+ ifdef TOOL_QT4_BIN_SUFF
+ TOOL_QT4_BIN_SUFF := $(TOOL_QT4_BIN_SUFF)
+ endif
+ # Try looking for moc-$(suffix) first, if specified.
+ ifneq ($(TOOL_QT4_BIN_SUFF),)
+ PATH_TOOL_QT4_BIN := $(patsubst %/moc$(TOOL_QT4_BIN_SUFF),%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/moc$(TOOL_QT4_BIN_SUFF)) \
+ /usr/lib/qt4/bin/moc$(TOOL_QT4_BIN_SUFF) \
+ /usr/qt/4/bin/moc$(TOOL_QT4_BIN_SUFF) \
+ /usr/share/qt4/bin/moc$(TOOL_QT4_BIN_SUFF) \
+ /usr/local/bin/moc$(TOOL_QT4_BIN_SUFF) \
+ /usr/bin/moc$(TOOL_QT4_BIN_SUFF) \
+ )))
+ else
+ # No suffix given, so before we check out -qt4 look at qt4 specific locations to avoid choosers and symlinks.
+ PATH_TOOL_QT4_BIN := $(patsubst %/moc,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/moc) \
+ $(if $(intersects $(KBUILD_HOST_ARCH), $(KBUILD_ARCHES_64)),/usr/lib64/qt4/bin/moc,) \
+ /usr/lib/qt4/bin/moc \
+ /usr/local/lib/qt4/bin/moc \
+ /usr/qt/4/bin/moc \
+ /usr/local/qt/4/bin/moc \
+ /usr/share/qt4/bin/moc \
+ /usr/local/share/qt4/bin/moc \
+ )))
+ ifeq ($(PATH_TOOL_QT4_BIN),)
+ PATH_TOOL_QT4_BIN := $(patsubst %/moc-qt4,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/moc-qt4) \
+ /usr/lib/qt4/bin/moc-qt4 \
+ /usr/qt/4/bin/moc-qt4 \
+ /usr/share/qt4/bin/moc-qt4 \
+ /usr/local/bin/moc-qt4 \
+ /usr/bin/moc-qt4 \
+ )))
+ ifneq ($(PATH_TOOL_QT4_BIN),)
+ TOOL_QT4_BIN_SUFF := -qt4
+ endif
+ endif
+ endif
+ # If still no go, try looking for qt3to4 and rcc.
+ ifeq ($(PATH_TOOL_QT4_BIN),)
+ PATH_TOOL_QT4_BIN := $(patsubst %/qt3to4,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/qt3to4) \
+ /usr/lib/qt4/bin/qt3to4 \
+ /usr/qt/4/bin/qt3to4 \
+ /usr/share/qt4/bin/qt3to4 \
+ /usr/local/bin/qt3to4 \
+ /usr/bin/qt3to4 \
+ )))
+ endif
+ ifeq ($(PATH_TOOL_QT4_BIN),)
+ PATH_TOOL_QT4_BIN := $(patsubst %/rcc$(TOOL_QT4_BIN_SUFF),%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF)) \
+ /usr/lib/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
+ /usr/qt/4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
+ /usr/share/qt4/bin/rcc$(TOOL_QT4_BIN_SUFF) \
+ /usr/local/bin/rcc$(TOOL_QT4_BIN_SUFF) \
+ /usr/bin/rcc$(TOOL_QT4_BIN_SUFF) \
+ )))
+ endif
+ if "$(PATH_TOOL_QT4_BIN)" == "" && "$(TOOL_QT4_BIN_SUFF)" != ""
+ PATH_TOOL_QT4_BIN := $(patsubst %/rcc,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt4/bin/rcc) \
+ /usr/lib/qt4/bin/rcc \
+ /usr/qt/4/bin/rcc \
+ /usr/share/qt4/bin/rcc \
+ /usr/local/bin/rcc \
+ /usr/bin/rcc \
+ )))
+ endif
+ ifneq ($(PATH_TOOL_QT4_BIN),)
+ export PATH_TOOL_QT4_BIN
+ endif
+ endif
+ # If not found, we'll enter the 'pathless' mode.
+else
+ # Resolve any fancy stuff once and for all.
+ PATH_TOOL_QT4_BIN := $(PATH_TOOL_QT4_BIN)
+endif
+ifneq ($(PATH_TOOL_QT4_BIN),)
+ TOOL_QT4_MOC ?= $(PATH_TOOL_QT4_BIN)/moc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT4_UIC ?= $(PATH_TOOL_QT4_BIN)/uic$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+ ifndef TOOL_QT4_RCC
+ TOOL_QT4_RCC := $(PATH_TOOL_QT4_BIN)/rcc$(HOST_SUFF_EXE)
+ ifeq ($(wildcard $(TOOL_QT4_RCC)),)
+ TOOL_QT4_RCC := $(PATH_TOOL_QT4_BIN)/rcc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+ endif
+ endif
+ TOOL_QT4_LRC ?= $(PATH_TOOL_QT4_BIN)/lrelease$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT4_LUPDATE ?= $(PATH_TOOL_QT4_BIN)/lupdate$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+else
+ # Pathless, relies on the environment.
+ TOOL_QT4_MOC ?= moc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT4_UIC ?= uic$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT4_RCC ?= rcc$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT4_LRC ?= lrelease$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+ TOOL_QT4_LUPDATE ?= lupdate$(TOOL_QT4_BIN_SUFF)$(HOST_SUFF_EXE)
+endif
+
+# General Properties used by kBuild and/or units/qt.kmk
+TOOL_QT4_MOCFLAGS ?=
+TOOL_QT4_MOCINCS ?=
+TOOL_QT4_MOCDEFS ?=
+TOOL_QT4_MOCDEFS.darwin ?= __APPLE__ __GNUC__
+TOOL_QT4_MOCDEFS.solaris ?= __sun
+TOOL_QT4_MOCDEFS.win.amd64 ?= WIN64
+TOOL_QT4_MOCDEFS.win.x86 ?= WIN32
+
+
+## MOC a C++ source file.
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT4_MOC_CPP_DEPEND =
+TOOL_QT4_MOC_CPP_DEPORD =
+TOOL_QT4_MOC_CPP_OUTPUT =
+TOOL_QT4_MOC_CPP_OUTPUT_MAYBE =
+define TOOL_QT4_MOC_CPP_CMDS
+ $(QUIET)$(TOOL_QT4_MOC)\
+ $(flags)\
+ $(addprefix -I, $(incs))\
+ $(addprefix -D, $(defs))\
+ -o $(out)\
+ $(source)
+endef
+
+## MOC a C++ header file.
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT4_MOC_HPP_DEPEND =
+TOOL_QT4_MOC_HPP_DEPORD =
+TOOL_QT4_MOC_HPP_OUTPUT =
+TOOL_QT4_MOC_HPP_OUTPUT_MAYBE =
+define TOOL_QT4_MOC_HPP_CMDS
+ $(QUIET)$(TOOL_QT4_MOC)\
+ $(flags)\
+ $(addprefix -I, $(incs))\
+ $(addprefix -D, $(defs))\
+ -o $(out)\
+ $(source)
+endef
+
+## Compile a Qt user interface file (.ui).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT4_UIC_UI_DEPEND =
+TOOL_QT4_UIC_UI_DEPORD =
+TOOL_QT4_UIC_UI_OUTPUT =
+TOOL_QT4_UIC_UI_OUTPUT_MAYBE =
+define TOOL_QT4_UIC_UI_CMDS
+ $(QUIET)$(TOOL_QT4_UIC)\
+ $(flags)\
+ -o $(out)\
+ $(source)
+endef
+
+## Compile a Qt resource file (.qrc).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+# @remarks The sed script generating the dependency file is a bit naive.
+TOOL_QT4_RCC_QRC_DEPEND =
+TOOL_QT4_RCC_QRC_DEPORD =
+TOOL_QT4_RCC_QRC_OUTPUT =
+TOOL_QT4_RCC_QRC_OUTPUT_MAYBE =
+define TOOL_QT4_RCC_QRC_CMDS
+ $(QUIET)$(TOOL_QT4_RCC)\
+ $(flags)\
+ -o $(out)\
+ $(source)
+ $(QUIET2)$(APPEND) $(dep) '\'
+ $(QUIET2)$(APPEND) $(dep) '$(out): \'
+ $(QUIET2)$(APPEND) $(dep) '$(source) \'
+ $(QUIET2)$(SED) \
+ -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
+ -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
+ -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
+ -e 's|$$$$| \\|' \
+ --append $(dep) \
+ $(source)
+ $(QUIET2)$(APPEND) $(dep)
+ $(QUIET2)$(SED) \
+ -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
+ -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
+ -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
+ -e 's|$$$$|:\n|' \
+ --append $(dep) \
+ $(source)
+ $(QUIET2)$(APPEND) $(dep)
+endef
+
+## Compile a Qt translation file (.ts).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT4_LRC_TS_DEPEND =
+TOOL_QT4_LRC_TS_DEPORD =
+TOOL_QT4_LRC_TS_OUTPUT =
+TOOL_QT4_LRC_TS_OUTPUT_MAYBE =
+define TOOL_QT4_LRC_TS_CMDS
+ $(QUIET)$(TOOL_QT4_LRC)\
+ $(flags)\
+ $(source)\
+ -qm $(out)
+endef
+
+
+
+#
+#
+# Back to the Qt4 unit.
+#
+#
+
+
+## wrapper for the lrelease (LRC) command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT4_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT4_LRC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt4_target_pre_handle_translation helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt4_target_pre_handle_translation_dx
+
+$(out) + $(more_output) +| $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT4_LRC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_LRC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
+$(target)-inst-nls_SOURCES += $(out)
+
+endef # def_unit_qt4_target_pre_handle_translation_dx
+
+##
+# Handle a source file listed in QT_TRANSLATIONS.
+#
+# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
+# to be translated into .qm files that are loadble by Qt.
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt4_target_pre_handle_translation
+local type := LRC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
+local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
+local out := $(outbase).qm
+local dep := $(out).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_LRC_TS_CMDS
+ $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
+local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
+local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt4_target_pre_handle_translation_dx))
+
+endef # def_unit_qt4_target_pre_handle_translation
+
+
+
+## wrapper for the UIC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT4_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT4_RCC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt4_target_pre_handle_qrc helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt4_target_pre_handle_rcc_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT4_RCC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_RCC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_GEN_SOURCES_ += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef # def_unit_qt4_target_pre_handle_rcc_dx
+
+##
+# Source handler for .qrc sources (Qt resource files).
+#
+# @remarks $(evalvalctx me).
+define def_unit_qt4_src_handler_qrc
+local type := RCC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
+local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.gen.cpp
+local realout := $(outbase).gen.cpp
+local dep := $(realout).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_RCC_QRC_CMDS
+ $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
+local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
+local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt4_target_pre_handle_rcc_dx))
+
+endef # def_unit_qt4_src_handler_qrc
+
+
+
+## wrapper for the UIC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT4_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT4_UIC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt4_src_handler_ui helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt4_target_pre_handle_ui_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT4_UIC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_UIC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef # def_unit_qt4_target_pre_handle_ui_dx
+
+##
+# Source handler for .ui sources.
+#
+# @remarks $(evalvalctx me).
+define def_unit_qt4_src_handler_ui
+local type := UIC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtuicdir := $($(target)_0_OUTDIR)/qtuic
+local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.gen.h
+local realout := $(outbase).gen.h
+local dep := $(realout).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_UIC_UI_CMDS
+ $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
+local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
+local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt4_target_pre_handle_ui_dx))
+
+endef # def_unit_qt4_src_handler_ui
+
+
+
+## wrapper for the MOC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT4_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT4_MOC_HPP_CMDS_DEP =
+endif
+
+##
+# def_unit_qt4_target_pre_handle_moc_hdr helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt4_target_pre_handle_moc_hdr_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT4_MOC_HPP_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_HPP_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_GEN_SOURCES_ += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef
+
+##
+# Handle a source file listed in QT_MOCHDRS.
+#
+# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
+# generate a .cpp file for each of them and add it to the generated
+# sources so that it's compiled and linked. (There is an alternative
+# way to do this where the .cpp file is included, this isn't currently
+# supported by this unit.)
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt4_target_pre_handle_moc_hdr
+local type := MOC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.cpp
+local realout := $(outbase).cpp
+local dep := $(realout).dep
+local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
+local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_MOC_HPP_CMDS
+ $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
+local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
+local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt4_target_pre_handle_moc_hdr_dx))
+
+endef # def_unit_qt4_target_pre_handle_moc_hdr
+
+
+## wrapper for the MOC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT4_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT4_MOC_CPP_CMDS_DEP =
+endif
+
+##
+# def_unit_qt4_target_pre_handle_moc_src helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt4_target_pre_handle_moc_src_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT4_MOC_CPP_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT4_MOC_CPP_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef
+
+##
+# Handle a source file listed in QT_MOCSRCS.
+#
+# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
+# a .moc file that we're expected to generate here.
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt4_target_pre_handle_moc_src
+local type := MOC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.moc
+local realout := $(outbase).moc
+local dep := $(realout).dep
+local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
+local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_MOC_CPP_CMDS
+ $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
+local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
+local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt4_target_pre_handle_moc_src_dx))
+
+endef # def_unit_qt4_target_pre_handle_moc_src
+
+
+##
+# Adds sources containing Q_OBJECT to QT_MOCSRCS.
+define def_unit_qt4_target_pre_cpp_source
+ifneq ($(file-size $(source)),-1)
+ ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
+ $(eval $(target)_QT_MOCSRCS += $(source))
+ endif
+endif
+endef # def_unit_qt4_target_pre_cpp_source
+
+##
+# Invoked early in the processing of a target that uses the Qt unit.
+#
+# It will append the qt source handlers to the target (.h, .ui, .ts,
+# .png, .bmp, .gif).
+#
+# It will then check all the C++ sources and check which needs
+# a .moc files and generate rules and dependencies fofor these
+#
+define def_unit_qt4_target_pre
+
+# Make QTTOOL the default for the specific Qt tools instead of TOOL.
+ifneq ($($(target)_QTTOOL),)
+ ifeq ($($(target)_MOCTOOL),)
+ $(target)_MOCTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_UICTOOL),)
+ $(target)_UICTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_RCCTOOL),)
+ $(target)_RCCTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_LRCTOOL),)
+ $(target)_LRCTOOL := $($(target)_QTTOOL)
+ endif
+endif
+
+# Deal with QT_MODULES, QT_PREFIX and QT_INFIX.
+local qt_modules := \
+ $($(target)_QT_MODULES.$(bld_trg)) \
+ $($(target)_QT_MODULES.$(bld_trg_arch)) \
+ $($(target)_QT_MODULES.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MODULES.$(bld_trg_cpu)) \
+ $($(target)_QT_MODULES.$(bld_type)) \
+ $($(target)_QT_MODULES)
+local qt_prefix := $(firstword \
+ $($(target)_QT_PREFIX.$(bld_trg)) \
+ $($(target)_QT_PREFIX.$(bld_trg_arch)) \
+ $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
+ $($(target)_QT_PREFIX.$(bld_type)) \
+ $($(target)_QT_PREFIX))
+local qt_infix := $(firstword \
+ $($(target)_QT_INFIX.$(bld_trg)) \
+ $($(target)_QT_INFIX.$(bld_trg_arch)) \
+ $($(target)_QT_INFIX.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_INFIX.$(bld_trg_cpu)) \
+ $($(target)_QT_INFIX.$(bld_type)) \
+ $($(target)_QT_INFIX))
+ifeq ($(bld_trg),darwin)
+ # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
+ $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT4_LIB) )
+ $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT4_LIB) )
+ $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT4_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) )
+ $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/4/Headers) )
+else
+ ifeq ($(bld_trg),win)
+ $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)$(qt_infix)4$(SUFF_LIB)) )
+ ifeq ($(tool_do),LINK_PROGRAM)
+ $(eval $(target)_LIBS += $(PATH_SDK_QT4_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) )
+ endif
+ else
+ $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/lib$(qt_prefix)Qt$(module)$(qt_infix)$(SUFF_DLL)) )
+ endif
+ $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT4_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT4_INC) )
+endif
+$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
+
+
+# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
+# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
+ifndef $(target)_QT_MOCSRCS
+ $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
+ $($(target)_SOURCES.$(bld_trg)) \
+ $($(target)_SOURCES.$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg_cpu)) \
+ $($(target)_SOURCES.$(bld_type)) \
+ $($(target)_SOURCES) \
+ ), $(evalval def_unit_qt4_target_pre_cpp_source))
+endif
+
+# Install source handlers for .ui files.
+$(target)_SRC_HANDLERS += \
+ .ui:def_unit_qt4_src_handler_ui \
+ .UI:def_unit_qt4_src_handler_ui \
+ .qrc:def_unit_qt4_src_handler_qrc \
+ .qrc:def_unit_qt4_src_handler_qrc
+
+# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
+local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
+local qtuicdir := $($(target)_0_OUTDIR)/qtuic
+local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
+local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
+$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
+$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
+
+# Deal with QT_MOCSRCS.
+$(foreach source, \
+ $($(target)_QT_MOCSRCS.$(bld_trg)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
+ $($(target)_QT_MOCSRCS.$(bld_type)) \
+ $($(target)_QT_MOCSRCS) \
+ , $(evalvalctx def_unit_qt4_target_pre_handle_moc_src))
+
+# Deal with QT_MOCHDRS.
+$(foreach source, \
+ $($(target)_QT_MOCHDRS.$(bld_trg)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
+ $($(target)_QT_MOCHDRS.$(bld_type)) \
+ $($(target)_QT_MOCHDRS) \
+ , $(evalvalctx def_unit_qt4_target_pre_handle_moc_hdr))
+
+# Deal with QT_TRANSLATIONS.
+# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
+local translations := \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_type)) \
+ $($(target)_QT_TRANSLATIONS)
+ifneq ($(strip $(translations)),)
+ local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
+ $(eval $(expr))
+ ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
+ $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
+ else
+ $(target)-inst-nls_MODE := 0644
+ endif
+ ifdef $(target)_QT_TRANSLATIONS_INST
+ $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
+ endif
+ $(target)-inst-nls_SOURCES :=
+ $(foreach source, $(translations)\
+ , $(evalvalctx def_unit_qt4_target_pre_handle_translation))
+endif
+
+endef # def_unit_qt4_target_pre
+
+
+#
+# Rule for debugging.
+#
+unit-qt4-show-vars:
+ @$(ECHO) 'The Qt4 SDK variables:'
+ @$(ECHO) ' PATH_SDK_QT4 = "$(PATH_SDK_QT4)"'
+ @$(ECHO) ' PATH_SDK_QT4_INC = "$(PATH_SDK_QT4_INC)"'
+ @$(ECHO) ' PATH_SDK_QT4_LIB = "$(PATH_SDK_QT4_LIB)"'
+ @$(ECHO) ' PATH_SDK_QT4_LIB.amd64 = "$(PATH_SDK_QT4_LIB.amd64)"'
+ @$(ECHO) ' PATH_SDK_QT4_LIB.x86 = "$(PATH_SDK_QT4_LIB.x86)"'
+ @$(ECHO) 'The Qt4 TOOL variables:'
+ @$(ECHO) ' PATH_TOOL_QT4_BIN = "$(PATH_TOOL_QT4_BIN)"'
+ @$(ECHO) ' TOOL_QT4_BIN_SUFF = "$(TOOL_QT4_BIN_SUFF)"'
+ @$(ECHO) ' TOOL_QT4_MOC = "$(TOOL_QT4_MOC)"'
+ @$(ECHO) ' TOOL_QT4_UIC = "$(TOOL_QT4_UIC)"'
+ @$(ECHO) ' TOOL_QT4_RCC = "$(TOOL_QT4_RCC)"'
+ @$(ECHO) ' TOOL_QT4_LRC = "$(TOOL_QT4_LRC)"'
+ @$(ECHO) ' TOOL_QT4_LUPDATE = "$(TOOL_QT4_LUPDATE)"'
+
diff --git a/kBuild/units/qt5.kmk b/kBuild/units/qt5.kmk
new file mode 100644
index 0000000..76353df
--- /dev/null
+++ b/kBuild/units/qt5.kmk
@@ -0,0 +1,1214 @@
+# $Id: qt5.kmk 3349 2020-05-23 09:54:19Z bird $
+## @file
+# Qt 5 unit.
+#
+
+#
+# Copyright (c) 2008-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+
+ifdef UNIT_qt5
+ $(error kBuild: The qt5 unit was included twice!)
+endif
+UNIT_qt5 = qt5
+
+
+if !defined(UNIT_qt3) && !defined(UNIT_qt4)
+ # Add our target properties (same as qt3 & qt4).
+ PROPS_SINGLE += QTTOOL MOCTOOL UICTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE QT_PREFIX
+ PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS LRCFLAGS QT_TRANSLATIONS QT_MOCSRCS QT_MOCHDRS
+endif
+PROPS_SINGLE += RCCTOOL QT_INFIX
+PROPS_ACCUMULATE_R += RCCFLAGS QT_MODULES
+
+
+## @todo use pkg-config?
+
+#
+# The QT5 SDK.
+#
+# This is implemented here rather than in sdks/QT5.kmk to enforce the global USES.
+# It also makes things easier to develop, with fewer files I mean.
+#
+## @todo the SDK might actually not be necessary as it turns out... For now it servers
+# a purpose if the host differs from the target, in theory at least.
+SDK_QT5 = Qt5
+
+# SDK Specific Properties
+# PATH_SDK_QT5 - The general Qt5 root directory.
+# PATH_SDK_QT5_INC - The include directory.
+# PATH_SDK_QT5_LIB.amd64 - The lib directory for AMD64.
+# PATH_SDK_QT5_LIB.x86 - The lib directory for X86.
+# PATH_SDK_QT5_LIB - The lib directory for KBUILD_TARGET.
+ifndef PATH_SDK_QT5
+ PATH_SDK_QT5 := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v5*)))
+ ifeq ($(PATH_SDK_QT5),)
+ # If target == host, try look for Qt in the various platform specific places.
+ ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
+ ifeq ($(KBUILD_TARGET),darwin)
+ PATH_SDK_QT5 := $(patsubst %/Frameworks/QtCore.framework/Versions/5,%,$(firstword $(wildcard /Library/Frameworks/QtCore.framework/Versions/5)))
+ else ifeq ($(KBUILD_TARGET),win)
+ # No idea here yet...
+ else ifeq ($(KBUILD_TARGET),ose)
+ # No port...
+ else
+ # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT5_LIB* stuff if it doesn't work.
+ # Try find the general root of thing by looking for the qt4to5 program, if not found, then look for rcc.
+ PATH_SDK_QT5 := $(patsubst %/bin/qt4to5-qt5,%,$(firstword $(wildcard \
+ /usr/bin/qt4to5-qt5 \
+ /usr/local/bin/qt4to5-qt5 \
+ /usr/qt/5/bin/qt4to5-qt5 \
+ /usr/share/qt5/bin/qt4to5-qt5 \
+ )))
+ ifeq ($(PATH_SDK_QT5),)
+ PATH_SDK_QT5 := $(patsubst %/bin/qt4to5,%,$(firstword $(wildcard \
+ /usr/bin/qt4to5 \
+ /usr/local/bin/qt4to5 \
+ /usr/qt/5/bin/qt4to5 \
+ /usr/share/qt5/bin/qt4to5 \
+ )))
+ endif
+ ifeq ($(PATH_SDK_QT5),)
+ PATH_SDK_QT5 := $(patsubst %/bin/rcc-qt5,%,$(firstword $(wildcard \
+ /usr/bin/rcc-qt5 \
+ /usr/local/bin/rcc-qt5 \
+ /usr/qt/5/bin/rcc-qt5 \
+ /usr/share/qt5/bin/rcc-qt5 \
+ )))
+ endif
+ ifeq ($(PATH_SDK_QT5),)
+ PATH_SDK_QT5 := $(patsubst %/bin/rcc,%,$(firstword $(wildcard \
+ /usr/lib/*/qt5/bin/rcc \
+ /usr/bin/rcc \
+ /usr/local/bin/rcc \
+ /usr/qt/5/bin/rcc \
+ /usr/share/qt5/bin/rcc \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT5),)
+ export PATH_SDK_QT5
+
+ # Locate the include files. Check for qglobalstatic.h (since 5.1) first.
+ ifeq ($(PATH_SDK_QT5_INC),)
+ PATH_SDK_QT5_INC := $(patsubst %/QtCore/qglobalstatic.h,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt5/QtCore/qglobalstatic.h) \
+ $(PATH_SDK_QT5)/include/qt5/QtCore/qglobalstatic.h \
+ /usr/include/qt5/QtCore/qtglobalstatic.h \
+ /usr/local/include/qt5/QtCore/qtglobalstatic.h \
+ $(PATH_SDK_QT5)/include/QtCore/qglobalstatic.h \
+ /usr/include/qt/QtCore/qglobalstatic.h \
+ /usr/local/include/qt/QtCore/qglobalstatic.h \
+ )))
+ ifeq ($(PATH_SDK_QT5_INC),)
+ PATH_SDK_QT5_INC := $(patsubst %/QtCore/qglobal.h,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt5/QtCore/qglobal.h) \
+ $(PATH_SDK_QT5)/include/qt5/QtCore/qglobal.h \
+ /usr/include/qt5/QtCore/qtglobal.h \
+ /usr/local/include/qt5/QtCore/qtglobal.h \
+ $(PATH_SDK_QT5)/include/QtCore/qglobal.h \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT5_INC),)
+ export PATH_SDK_QT5_INC
+ endif
+ endif
+
+ # Now for the libraries (mostly for helping out finding the KBUILD_TARGET libs).
+ ifeq ($(PATH_SDK_QT5_LIB.x86),)
+ PATH_SDK_QT5_LIB.x86 := $(patsubst %/libQt5Core$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT5)/lib32/libQt5Core$(SUFF_DLL) \
+ $(PATH_SDK_QT5)/lib32/qt5/libQt5Core$(SUFF_DLL) \
+ /usr/lib32/libQt5Core$(SUFF_DLL) \
+ /usr/lib32/qt5/libQt5Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/lib/$(type)/libQt5Core$(SUFF_DLL)) \
+ /usr/local/lib32/libQt5Core$(SUFF_DLL) \
+ /usr/local/lib32/qt5/libQt5Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/local/lib/$(type)/libQt5Core$(SUFF_DLL)) \
+ $(PATH_SDK_QT5)/lib/libQt5Core$(SUFF_DLL) \
+ $(PATH_SDK_QT5)/lib/qt5/libQt5Core$(SUFF_DLL) \
+ $(PATH_SDK_QT5)/lib/i386-linux-gnu/libQt5Core$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT5_LIB.x86),)
+ export PATH_SDK_QT5_LIB.x86
+ endif
+ endif
+ ifeq ($(PATH_SDK_QT5_LIB.amd64),)
+ PATH_SDK_QT5_LIB.amd64 := $(patsubst %/libQt5Core$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT5)/lib64/libQt5Core$(SUFF_DLL) \
+ $(PATH_SDK_QT5)/lib64/qt5/libQt5Core$(SUFF_DLL) \
+ $(PATH_SDK_QT5)/lib/amd64/libQt5Core$(SUFF_DLL) \
+ /usr/lib64/libQt5Core$(SUFF_DLL) \
+ /usr/lib64/qt5/libQt5Core$(SUFF_DLL) \
+ /usr/lib/amd64/libQt5Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/lib/$(type)/libQt5Core$(SUFF_DLL)) \
+ /usr/local/lib64/libQt5Core$(SUFF_DLL) \
+ /usr/local/lib64/qt5/libQt5Core$(SUFF_DLL) \
+ /usr/local/lib/amd64/libQt5Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/local/lib/$(type)/libQt5Core$(SUFF_DLL)) \
+ $(PATH_SDK_QT5)/lib/libQt5Core$(SUFF_DLL) \
+ $(PATH_SDK_QT5)/lib/qt5/libQt5Core$(SUFF_DLL) \
+ $(PATH_SDK_QT5)/lib/x86_64-linux-gnu/libQt5Core$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT5_LIB.amd64),)
+ export PATH_SDK_QT5_LIB.amd64
+ endif
+ endif
+
+ # And finally, the library path for KBUILD_TARGET.
+ ifeq ($(PATH_SDK_QT5_LIB),)
+ PATH_SDK_QT5_LIB := $(PATH_SDK_QT5_LIB.$(KBUILD_TARGET_ARCH))
+ ifeq ($(PATH_SDK_QT5_LIB),)
+ PATH_SDK_QT5_LIB := $(patsubst %/libQt5Core$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT5)/lib/libQt5Core$(SUFF_DLL) \
+ $(PATH_SDK_QT5)/lib/qt5/libQt5Core$(SUFF_DLL) \
+ /usr/lib/libQt5Core$(SUFF_DLL) \
+ /usr/lib/qt5/libQt5Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/lib/$(type)/libQt5Core$(SUFF_DLL)) \
+ /usr/local/lib/libQt5Core$(SUFF_DLL) \
+ /usr/local/lib/qt5/libQt5Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/local/lib/$(type)/libQt5Core$(SUFF_DLL)) \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT5_LIB),)
+ export PATH_SDK_QT5_LIB
+ endif
+ endif
+
+ endif
+ endif # Unices
+ endif
+ # Found it?
+ ifeq ($(PATH_SDK_QT5),)
+ $(warning kBuild: Couldn't find the Qt5 headers and libaries...)
+ PATH_SDK_QT5 := $(KBUILD_DEVTOOLS_TRG)/qt/not-found
+ endif
+ endif
+else
+ # Resolve any fancy stuff once and for all.
+ PATH_SDK_QT5 := $(PATH_SDK_QT5)
+endif
+
+# Libraries can be in either Frameworks or lib depending on how you
+# build it on the mac. The .dmg installs into Frameworks but builds into lib.
+ifeq ($(KBUILD_TARGET),darwin)
+ ifndef PATH_SDK_QT5_LIB
+ ifneq ($(wildcard $(PATH_SDK_QT5)/Frameworks),)
+ PATH_SDK_QT5_LIB ?= $(PATH_SDK_QT5)/Frameworks
+ else
+ PATH_SDK_QT5_LIB ?= $(PATH_SDK_QT5)/lib
+ endif
+ endif
+else
+ PATH_SDK_QT5_LIB ?= $(PATH_SDK_QT5)/lib
+ PATH_SDK_QT5_INC ?= $(PATH_SDK_QT5)/include
+endif
+
+# The bits that kBuild picks up.
+# (nothing here)
+
+
+#
+# The QT5 tool.
+#
+# This is implemented here rather than in tools/QT5.kmk to enforce the global USES.
+# It also makes things easier to develop, with fewer files I mean.
+#
+TOOL_QT5 = Qt5
+
+# Tool Specific Properties
+# PATH_TOOL_QT5 - Obsolete.
+# PATH_TOOL_QT5_BIN - The
+# TOOL_QT5_BIN_SUFF -
+if !defined(PATH_TOOL_QT5_BIN) && defined(PATH_TOOL_QT5)
+ PATH_TOOL_QT5_BIN := $(PATH_TOOL_QT5)/bin
+endif
+ifndef PATH_TOOL_QT5_BIN
+ PATH_TOOL_QT5_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST)/qt/v5*/bin)))
+ if "$(PATH_TOOL_QT5_BIN)" == "" && "$(KBUILD_DEVTOOLS_HST_ALT)" != ""
+ PATH_TOOL_QT5_BIN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST_ALT)/qt/v5*/bin)))
+ endif
+ ifeq ($(PATH_TOOL_QT5_BIN),)
+ ifdef TOOL_QT5_BIN_SUFF
+ TOOL_QT5_BIN_SUFF := $(TOOL_QT5_BIN_SUFF)
+ endif
+ # Try looking for moc-qt5 / moc-$(suffix) first.
+ ifneq ($(TOOL_QT5_BIN_SUFF),)
+ PATH_TOOL_QT5_BIN := $(patsubst %/moc$(TOOL_QT5_BIN_SUFF),%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/moc$(TOOL_QT5_BIN_SUFF)) \
+ /usr/lib/qt5/bin/moc$(TOOL_QT5_BIN_SUFF) \
+ /usr/qt/5/bin/moc$(TOOL_QT5_BIN_SUFF) \
+ /usr/share/qt5/bin/moc$(TOOL_QT5_BIN_SUFF) \
+ /usr/local/bin/moc$(TOOL_QT5_BIN_SUFF) \
+ /usr/bin/moc$(TOOL_QT5_BIN_SUFF) \
+ )))
+ else
+ # No suffix given, so before we check out -qt5 look at qt5 specific locations to avoid choosers and symlinks.
+ PATH_TOOL_QT5_BIN := $(patsubst %/moc,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/moc) \
+ $(if $(intersects $(KBUILD_HOST_ARCH), $(KBUILD_ARCHES_64)),/usr/lib64/qt5/bin/moc,) \
+ /usr/lib/qt5/bin/moc \
+ /usr/local/lib/qt5/bin/moc \
+ /usr/qt/5/bin/moc \
+ /usr/local/qt/5/bin/moc \
+ /usr/share/qt5/bin/moc \
+ /usr/local/share/qt5/bin/moc \
+ )))
+ ifeq ($(PATH_TOOL_QT5_BIN),)
+ PATH_TOOL_QT5_BIN := $(patsubst %/moc-qt5,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/moc-qt5) \
+ /usr/lib/qt5/bin/moc-qt5 \
+ /usr/qt/5/bin/moc-qt5 \
+ /usr/share/qt5/bin/moc-qt5 \
+ /usr/local/bin/moc-qt5 \
+ /usr/bin/moc-qt5 \
+ )))
+ ifneq ($(PATH_TOOL_QT5_BIN),)
+ TOOL_QT5_BIN_SUFF := -qt5
+ endif
+ endif
+ endif
+ # If still no go, try looking for qt4to5 and rcc.
+ ifeq ($(PATH_TOOL_QT5_BIN),)
+ PATH_TOOL_QT5_BIN := $(patsubst %/qt4to5,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/qt4to5) \
+ /usr/lib/qt5/bin/qt4to5 \
+ /usr/qt/5/bin/qt4to5 \
+ /usr/share/qt5/bin/qt4to5 \
+ /usr/local/bin/qt4to5 \
+ /usr/bin/qt4to5 \
+ )))
+ endif
+ ifeq ($(PATH_TOOL_QT5_BIN),)
+ PATH_TOOL_QT5_BIN := $(patsubst %/rcc$(TOOL_QT5_BIN_SUFF),%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/rcc$(TOOL_QT5_BIN_SUFF)) \
+ /usr/lib/qt5/bin/rcc$(TOOL_QT5_BIN_SUFF) \
+ /usr/qt/5/bin/rcc$(TOOL_QT5_BIN_SUFF) \
+ /usr/share/qt5/bin/rcc$(TOOL_QT5_BIN_SUFF) \
+ /usr/local/bin/rcc$(TOOL_QT5_BIN_SUFF) \
+ /usr/bin/rcc$(TOOL_QT5_BIN_SUFF) \
+ )))
+ endif
+ if "$(PATH_TOOL_QT5_BIN)" == "" && "$(TOOL_QT5_BIN_SUFF)" != ""
+ PATH_TOOL_QT5_BIN := $(patsubst %/rcc,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt5/bin/rcc) \
+ /usr/lib/qt5/bin/rcc \
+ /usr/qt/5/bin/rcc \
+ /usr/share/qt5/bin/rcc \
+ /usr/local/bin/rcc \
+ /usr/bin/rcc \
+ )))
+ endif
+ ifneq ($(PATH_TOOL_QT5_BIN),)
+ export PATH_TOOL_QT5_BIN
+ endif
+ endif
+ # If not found, we'll enter the 'pathless' mode.
+else
+ # Resolve any fancy stuff once and for all.
+ PATH_TOOL_QT5_BIN := $(PATH_TOOL_QT5_BIN)
+endif
+ifneq ($(PATH_TOOL_QT5_BIN),)
+ TOOL_QT5_MOC ?= $(PATH_TOOL_QT5_BIN)/moc$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT5_UIC ?= $(PATH_TOOL_QT5_BIN)/uic$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+ ifndef TOOL_QT5_RCC
+ TOOL_QT5_RCC := $(PATH_TOOL_QT5_BIN)/rcc$(HOSTSUFF_EXE)
+ ifeq ($(wildcard $(TOOL_QT5_RCC)),)
+ TOOL_QT5_RCC := $(PATH_TOOL_QT5_BIN)/rcc$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+ endif
+ endif
+ TOOL_QT5_LRC ?= $(PATH_TOOL_QT5_BIN)/lrelease$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT5_LUPDATE ?= $(PATH_TOOL_QT5_BIN)/lupdate$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+else
+ # Pathless, relies on the environment.
+ TOOL_QT5_MOC ?= moc$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT5_UIC ?= uic$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT5_RCC ?= rcc$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT5_LRC ?= lrelease$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT5_LUPDATE ?= lupdate$(TOOL_QT5_BIN_SUFF)$(HOSTSUFF_EXE)
+endif
+ifdef TOOL_QT5_USE_KSUBMIT
+ ifeq ($(KBUILD_HOST),win)
+ TOOL_QT5_MOC_KSUBMIT ?= kmk_builtin_kSubmit --$(SP)
+ endif
+endif
+
+# General Properties used by kBuild and/or units/qt.kmk
+TOOL_QT5_MOCFLAGS ?=
+TOOL_QT5_MOCINCS ?=
+TOOL_QT5_MOCDEFS ?=
+TOOL_QT5_MOCDEFS.darwin ?= __APPLE__ __GNUC__
+TOOL_QT5_MOCDEFS.solaris ?= __sun
+TOOL_QT5_MOCDEFS.win.amd64 ?= WIN64
+TOOL_QT5_MOCDEFS.win.x86 ?= WIN32
+
+
+## MOC a C++ source file.
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT5_MOC_CPP_DEPEND =
+TOOL_QT5_MOC_CPP_DEPORD =
+TOOL_QT5_MOC_CPP_OUTPUT =
+TOOL_QT5_MOC_CPP_OUTPUT_MAYBE =
+ifdef KMK_WITH_QUOTING
+ define TOOL_QT5_MOC_CPP_CMDS
+ $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
+ $(flags)\
+ $(qaddprefix sh,-I, $(incs))\
+ $(qaddprefix sh,-D, $(defs))\
+ -o $(out)\
+ $(source)
+ endef
+else
+ define TOOL_QT5_MOC_CPP_CMDS
+ $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
+ $(flags)\
+ $(addprefix -I, $(incs))\
+ $(addprefix -D, $(defs))\
+ -o $(out)\
+ $(source)
+ endef
+endif
+
+## MOC a C++ header file.
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT5_MOC_HPP_DEPEND =
+TOOL_QT5_MOC_HPP_DEPORD =
+TOOL_QT5_MOC_HPP_OUTPUT =
+TOOL_QT5_MOC_HPP_OUTPUT_MAYBE =
+ifdef KMK_WITH_QUOTING
+ define TOOL_QT5_MOC_HPP_CMDS
+ $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
+ $(flags)\
+ $(qaddprefix sh,-I, $(incs))\
+ $(qaddprefix sh,-D, $(defs))\
+ -o $(out)\
+ $(source)
+ endef
+else
+ define TOOL_QT5_MOC_HPP_CMDS
+ $(QUIET)$(TOOL_QT5_MOC_KSUBMIT)$(TOOL_QT5_MOC)\
+ $(flags)\
+ $(addprefix -I, $(incs))\
+ $(addprefix -D, $(defs))\
+ -o $(out)\
+ $(source)
+ endef
+endif
+
+## Compile a Qt user interface file (.ui).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT5_UIC_UI_DEPEND =
+TOOL_QT5_UIC_UI_DEPORD =
+TOOL_QT5_UIC_UI_OUTPUT =
+TOOL_QT5_UIC_UI_OUTPUT_MAYBE =
+define TOOL_QT5_UIC_UI_CMDS
+ $(QUIET)$(TOOL_QT5_UIC)\
+ $(flags)\
+ -o $(out)\
+ $(source)
+endef
+
+## Compile a Qt resource file (.qrc).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+# @remarks The sed script generating the dependency file is a bit naive.
+TOOL_QT5_RCC_QRC_DEPEND =
+TOOL_QT5_RCC_QRC_DEPORD =
+TOOL_QT5_RCC_QRC_OUTPUT =
+TOOL_QT5_RCC_QRC_OUTPUT_MAYBE =
+define TOOL_QT5_RCC_QRC_CMDS
+ $(QUIET)$(TOOL_QT5_RCC)\
+ $(flags)\
+ -o $(out)\
+ $(source)
+ $(QUIET2)$(APPEND) -n $(dep) '\' \
+ '$(out): \' \
+ '$(source) \'
+ $(QUIET2)$(SED) \
+ -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
+ -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
+ -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
+ -e 's|$$$$| \\|' \
+ --append $(dep) \
+ $(source)
+ $(QUIET2)$(APPEND) $(dep)
+ $(QUIET2)$(SED) \
+ -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
+ -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
+ -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
+ -e 's|$$$$|:\n|' \
+ --append $(dep) \
+ $(source)
+ $(QUIET2)$(APPEND) $(dep)
+endef
+
+## Compile a Qt translation file (.ts).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT5_LRC_TS_DEPEND =
+TOOL_QT5_LRC_TS_DEPORD =
+TOOL_QT5_LRC_TS_OUTPUT =
+TOOL_QT5_LRC_TS_OUTPUT_MAYBE =
+define TOOL_QT5_LRC_TS_CMDS
+ $(QUIET)$(TOOL_QT5_LRC)\
+ $(flags)\
+ $(source)\
+ -qm $(out)
+endef
+
+
+
+#
+#
+# Back to the Qt5 unit.
+#
+#
+
+
+## wrapper for the lrelease (LRC) command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT5_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT5_LRC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt5_target_pre_handle_translation helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt5_target_pre_handle_translation_dx
+
+$(out) + $(more_output) +| $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT5_LRC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_LRC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
+$(target)-inst-nls_SOURCES += $(out)
+
+endef # def_unit_qt5_target_pre_handle_translation_dx
+
+##
+# Handle a source file listed in QT_TRANSLATIONS.
+#
+# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
+# to be translated into .qm files that are loadble by Qt.
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt5_target_pre_handle_translation
+local type := LRC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
+local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
+local out := $(outbase).qm
+local dep := $(out).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_LRC_TS_CMDS
+ $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
+local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
+local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt5_target_pre_handle_translation_dx))
+
+endef # def_unit_qt5_target_pre_handle_translation
+
+
+
+## wrapper for the UIC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT5_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT5_RCC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt5_target_pre_handle_qrc helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt5_target_pre_handle_rcc_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT5_RCC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_RCC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_GEN_SOURCES_ += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef # def_unit_qt5_target_pre_handle_rcc_dx
+
+##
+# Source handler for .qrc sources (Qt resource files).
+#
+# @remarks $(evalvalctx me).
+define def_unit_qt5_src_handler_qrc
+local type := RCC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
+local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.gen.cpp
+local realout := $(outbase).gen.cpp
+local dep := $(realout).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_RCC_QRC_CMDS
+ $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
+local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
+local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt5_target_pre_handle_rcc_dx))
+
+endef # def_unit_qt5_src_handler_qrc
+
+
+
+## wrapper for the UIC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT5_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT5_UIC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt5_src_handler_ui helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt5_target_pre_handle_ui_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT5_UIC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_UIC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef # def_unit_qt5_target_pre_handle_ui_dx
+
+##
+# Source handler for .ui sources.
+#
+# @remarks $(evalvalctx me).
+define def_unit_qt5_src_handler_ui
+local type := UIC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtuicdir := $($(target)_0_OUTDIR)/qtuic
+local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.gen.h
+local realout := $(outbase).gen.h
+local dep := $(realout).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_UIC_UI_CMDS
+ $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
+local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
+local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt5_target_pre_handle_ui_dx))
+
+endef # def_unit_qt5_src_handler_ui
+
+
+
+## wrapper for the MOC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT5_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT5_MOC_HPP_CMDS_DEP =
+endif
+
+##
+# def_unit_qt5_target_pre_handle_moc_hdr helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt5_target_pre_handle_moc_hdr_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT5_MOC_HPP_CMDS_DEP) \
+ | \
+ $(orderdeps) $(my_target_intermediate_vars)
+ %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_MOC_HPP_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_GEN_SOURCES_ += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef
+
+##
+# Handle a source file listed in QT_MOCHDRS.
+#
+# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
+# generate a .cpp file for each of them and add it to the generated
+# sources so that it's compiled and linked. (There is an alternative
+# way to do this where the .cpp file is included, this isn't currently
+# supported by this unit.)
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt5_target_pre_handle_moc_hdr
+local type := MOC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.cpp
+local realout := $(outbase).cpp
+local dep := $(realout).dep
+local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
+local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_MOC_HPP_CMDS
+ $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
+local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
+local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt5_target_pre_handle_moc_hdr_dx))
+
+endef # def_unit_qt5_target_pre_handle_moc_hdr
+
+
+## wrapper for the MOC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT5_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT5_MOC_CPP_CMDS_DEP =
+endif
+
+##
+# def_unit_qt5_target_pre_handle_moc_src helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt5_target_pre_handle_moc_src_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT5_MOC_CPP_CMDS_DEP) \
+ | \
+ $(orderdeps) $(my_target_intermediate_vars)
+ %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT5_MOC_CPP_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef
+
+##
+# Handle a source file listed in QT_MOCSRCS.
+#
+# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
+# a .moc file that we're expected to generate here.
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt5_target_pre_handle_moc_src
+local type := MOC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.moc
+local realout := $(outbase).moc
+local dep := $(realout).dep
+local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
+local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_MOC_CPP_CMDS
+ $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
+local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
+local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt5_target_pre_handle_moc_src_dx))
+
+endef # def_unit_qt5_target_pre_handle_moc_src
+
+
+##
+# Adds sources containing Q_OBJECT to QT_MOCSRCS.
+define def_unit_qt5_target_pre_cpp_source
+ifneq ($(file-size $(source)),-1)
+ ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
+ $(eval $(target)_QT_MOCSRCS += $(source))
+ endif
+endif
+endef # def_unit_qt5_target_pre_cpp_source
+
+##
+# Invoked early in the processing of a target that uses the Qt unit.
+#
+# It will append the qt source handlers to the target (.h, .ui, .ts,
+# .png, .bmp, .gif).
+#
+# It will then check all the C++ sources and check which needs
+# a .moc files and generate rules and dependencies fofor these
+#
+define def_unit_qt5_target_pre
+
+# Make QTTOOL the default for the specific Qt tools instead of TOOL.
+ifneq ($($(target)_QTTOOL),)
+ ifeq ($($(target)_MOCTOOL),)
+ $(target)_MOCTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_UICTOOL),)
+ $(target)_UICTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_RCCTOOL),)
+ $(target)_RCCTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_LRCTOOL),)
+ $(target)_LRCTOOL := $($(target)_QTTOOL)
+ endif
+endif
+
+# Deal with QT_MODULES, QT_PREFIX and QT_INFIX.
+local qt_modules := \
+ $($(target)_QT_MODULES.$(bld_trg)) \
+ $($(target)_QT_MODULES.$(bld_trg_arch)) \
+ $($(target)_QT_MODULES.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MODULES.$(bld_trg_cpu)) \
+ $($(target)_QT_MODULES.$(bld_type)) \
+ $($(target)_QT_MODULES)
+local qt_prefix := $(firstword \
+ $($(target)_QT_PREFIX.$(bld_trg)) \
+ $($(target)_QT_PREFIX.$(bld_trg_arch)) \
+ $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
+ $($(target)_QT_PREFIX.$(bld_type)) \
+ $($(target)_QT_PREFIX))
+local qt_infix := $(firstword \
+ $($(target)_QT_INFIX.$(bld_trg)) \
+ $($(target)_QT_INFIX.$(bld_trg_arch)) \
+ $($(target)_QT_INFIX.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_INFIX.$(bld_trg_cpu)) \
+ $($(target)_QT_INFIX.$(bld_type)) \
+ $($(target)_QT_INFIX))
+ifeq ($(bld_trg),darwin)
+ # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
+ $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT5_LIB) )
+ $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT5_LIB) )
+ $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT5_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) )
+ $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/5/Headers) )
+else
+ ifeq ($(bld_trg),win)
+ $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_LIB)) )
+ ifeq ($(tool_do),LINK_PROGRAM)
+ $(eval $(target)_LIBS += $(PATH_SDK_QT5_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) )
+ endif
+ else
+ $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/lib$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_DLL)) )
+ endif
+ $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT5_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT5_INC) )
+endif
+$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
+
+
+# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
+# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
+ifndef $(target)_QT_MOCSRCS
+ $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
+ $($(target)_SOURCES.$(bld_trg)) \
+ $($(target)_SOURCES.$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg_cpu)) \
+ $($(target)_SOURCES.$(bld_type)) \
+ $($(target)_SOURCES) \
+ ), $(evalval def_unit_qt5_target_pre_cpp_source))
+endif
+
+# Install source handlers for .ui files.
+$(target)_SRC_HANDLERS += \
+ .ui:def_unit_qt5_src_handler_ui \
+ .UI:def_unit_qt5_src_handler_ui \
+ .qrc:def_unit_qt5_src_handler_qrc \
+ .qrc:def_unit_qt5_src_handler_qrc
+
+# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
+local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
+local qtuicdir := $($(target)_0_OUTDIR)/qtuic
+local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
+local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
+$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
+$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
+
+# Since we add a lot of stuff to 2_INTERMEDIATES, we must exclude it from the intermediates
+# used by the rules we generate to avoid circular dependencies.
+local my_target_intermediate_vars := $(filter-out %_2_INTERMEDIATES$(CLOSEPAR),$(target_intermediate_vars))
+
+# Deal with QT_MOCSRCS.
+$(foreach source, \
+ $($(target)_QT_MOCSRCS.$(bld_trg)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
+ $($(target)_QT_MOCSRCS.$(bld_type)) \
+ $($(target)_QT_MOCSRCS) \
+ , $(evalvalctx def_unit_qt5_target_pre_handle_moc_src))
+
+# Deal with QT_MOCHDRS.
+$(foreach source, \
+ $($(target)_QT_MOCHDRS.$(bld_trg)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
+ $($(target)_QT_MOCHDRS.$(bld_type)) \
+ $($(target)_QT_MOCHDRS) \
+ , $(evalvalctx def_unit_qt5_target_pre_handle_moc_hdr))
+
+# Deal with QT_TRANSLATIONS.
+# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
+local translations := \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_type)) \
+ $($(target)_QT_TRANSLATIONS)
+ifneq ($(strip $(translations)),)
+ local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
+ $(eval $(expr))
+ ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
+ $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
+ else
+ $(target)-inst-nls_MODE := 0644
+ endif
+ ifdef $(target)_QT_TRANSLATIONS_INST
+ $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
+ endif
+ $(target)-inst-nls_SOURCES :=
+ $(foreach source, $(translations)\
+ , $(evalvalctx def_unit_qt5_target_pre_handle_translation))
+endif
+
+endef # def_unit_qt5_target_pre
+
+
+#
+# Rule for debugging.
+#
+unit-qt5-show-vars:
+ @$(ECHO) 'The Qt5 SDK variables:'
+ @$(ECHO) ' PATH_SDK_QT5 = "$(PATH_SDK_QT5)"'
+ @$(ECHO) ' PATH_SDK_QT5_INC = "$(PATH_SDK_QT5_INC)"'
+ @$(ECHO) ' PATH_SDK_QT5_LIB = "$(PATH_SDK_QT5_LIB)"'
+ @$(ECHO) ' PATH_SDK_QT5_LIB.amd64 = "$(PATH_SDK_QT5_LIB.amd64)"'
+ @$(ECHO) ' PATH_SDK_QT5_LIB.x86 = "$(PATH_SDK_QT5_LIB.x86)"'
+ @$(ECHO) 'The Qt5 TOOL variables:'
+ @$(ECHO) ' PATH_TOOL_QT5_BIN = "$(PATH_TOOL_QT5_BIN)"'
+ @$(ECHO) ' TOOL_QT5_BIN_SUFF = "$(TOOL_QT5_BIN_SUFF)"'
+ @$(ECHO) ' TOOL_QT5_MOC = "$(TOOL_QT5_MOC)"'
+ @$(ECHO) ' TOOL_QT5_UIC = "$(TOOL_QT5_UIC)"'
+ @$(ECHO) ' TOOL_QT5_RCC = "$(TOOL_QT5_RCC)"'
+ @$(ECHO) ' TOOL_QT5_LRC = "$(TOOL_QT5_LRC)"'
+ @$(ECHO) ' TOOL_QT5_LUPDATE = "$(TOOL_QT5_LUPDATE)"'
+
diff --git a/kBuild/units/qt6.kmk b/kBuild/units/qt6.kmk
new file mode 100644
index 0000000..fc3d91c
--- /dev/null
+++ b/kBuild/units/qt6.kmk
@@ -0,0 +1,1244 @@
+# $Id: qt6.kmk 3559 2022-03-02 01:47:27Z bird $
+## @file
+# Qt 6 unit.
+#
+
+#
+# Copyright (c) 2008-2022 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+
+ifdef UNIT_qt6
+ $(error kBuild: The qt6 unit was included twice!)
+endif
+UNIT_qt6 = qt6
+
+
+if !defined(UNIT_qt3) && !defined(UNIT_qt4)
+ # Add our target properties (same as qt3 & qt4).
+ PROPS_SINGLE += QTTOOL MOCTOOL UICTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE QT_PREFIX
+ PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS LRCFLAGS QT_TRANSLATIONS QT_MOCSRCS QT_MOCHDRS
+endif
+PROPS_SINGLE += RCCTOOL QT_INFIX
+PROPS_ACCUMULATE_R += RCCFLAGS QT_MODULES
+
+
+## @todo use pkg-config?
+
+#
+# The QT6 SDK.
+#
+# This is implemented here rather than in sdks/QT6.kmk to enforce the global USES.
+# It also makes things easier to develop, with fewer files I mean.
+#
+## @todo the SDK might actually not be necessary as it turns out... For now it servers
+# a purpose if the host differs from the target, in theory at least.
+SDK_QT6 = Qt6
+
+# SDK Specific Properties
+# PATH_SDK_QT6 - The general Qt6 root directory.
+# PATH_SDK_QT6_INC - The include directory.
+# PATH_SDK_QT6_LIB.amd64 - The lib directory for AMD64.
+# PATH_SDK_QT6_LIB.x86 - The lib directory for X86.
+# PATH_SDK_QT6_LIB - The lib directory for KBUILD_TARGET.
+ifndef PATH_SDK_QT6
+ PATH_SDK_QT6 := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_TRG)/qt/v6*)))
+ ifeq ($(PATH_SDK_QT6),)
+ # If target == host, try look for Qt in the various platform specific places.
+ ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
+ ifeq ($(KBUILD_TARGET),darwin)
+ PATH_SDK_QT6 := $(patsubst %/Frameworks/QtCore.framework/Versions/6,%,$(firstword $(wildcard /Library/Frameworks/QtCore.framework/Versions/6)))
+ else ifeq ($(KBUILD_TARGET),win)
+ # No idea here yet...
+ else ifeq ($(KBUILD_TARGET),ose)
+ # No port...
+ else
+ # The Unices. Includes and esp. libs are tricky, so override the PATH_SDK_QT6_LIB* stuff if it doesn't work.
+ # Try find the general root of thing by looking for the rcc program, as there seems to be no qt6 specific one to look for.
+ PATH_SDK_QT6 := $(patsubst %/bin/rcc-qt6,%,$(firstword $(wildcard \
+ /usr/bin/rcc-qt6 \
+ /usr/local/bin/rcc-qt6 \
+ /usr/qt/6/bin/rcc-qt6 \
+ $(if $(intersects $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES_64)),/usr/lib64/qt6/bin/rcc-qt6) \
+ /usr/lib/qt6/bin/rcc-qt6 \
+ /usr/share/qt6/bin/rcc-qt6 \
+ )))
+ ifeq ($(PATH_SDK_QT6),)
+ PATH_SDK_QT6 := $(patsubst %/libexec/rcc-qt6,%,$(firstword $(wildcard \
+ /usr/libexec/rcc-qt6 \
+ /usr/local/libexec/rcc-qt6 \
+ /usr/qt/6/libexec/rcc-qt6 \
+ $(if $(intersects $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES_64)),/usr/lib64/qt6/libexec/rcc-qt6) \
+ /usr/lib/qt6/libexec/rcc-qt6 \
+ /usr/share/qt6/libexec/rcc-qt6 \
+ )))
+ endif
+ ifeq ($(PATH_SDK_QT6),)
+ PATH_SDK_QT6 := $(patsubst %/libexec/rcc,%,$(firstword $(wildcard \
+ /usr/qt/6/libexec/rcc \
+ $(if $(intersects $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES_64)),/usr/lib64/qt6/libexec/rcc) \
+ /usr/lib/qt6/libexec/rcc \
+ /usr/share/qt6/libexec/rcc \
+ /usr/libexec/rcc \
+ /usr/local/libexec/rcc \
+ )))
+ endif
+ ifeq ($(PATH_SDK_QT6),)
+ PATH_SDK_QT6 := $(patsubst %/bin/rcc,%,$(firstword $(wildcard \
+ /usr/qt/6/bin/rcc \
+ $(if $(intersects $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES_64)),/usr/lib64/qt6/bin/rcc) \
+ /usr/lib/qt6/bin/rcc \
+ /usr/share/qt6/bin/rcc \
+ /usr/bin/rcc \
+ /usr/local/bin/rcc \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT6),)
+ export PATH_SDK_QT6
+
+ # Locate the include files. Check for QStringConverter (since 6.?) first.
+ ifeq ($(PATH_SDK_QT6_INC),)
+ PATH_SDK_QT6_INC := $(patsubst %/QtCore/QStringConverter,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt6/QtCore/QStringConverter) \
+ $(PATH_SDK_QT6)/include/qt6/QtCore/QStringConverter \
+ /usr/include/qt6/QtCore/QStringConverter \
+ /usr/local/include/qt6/QtCore/QStringConverter \
+ $(PATH_SDK_QT6)/include/QtCore/QStringConverter \
+ /usr/include/qt/QtCore/QStringConverter \
+ /usr/local/include/qt/QtCore/QStringConverter \
+ )))
+ ifeq ($(PATH_SDK_QT6_INC),)
+ PATH_SDK_QT6_INC := $(patsubst %/QtCore/qglobal.h,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/include/$(type)/qt6/QtCore/qglobal.h) \
+ $(PATH_SDK_QT6)/include/qt6/QtCore/qglobal.h \
+ /usr/include/qt6/QtCore/qglobal.h \
+ /usr/local/include/qt6/QtCore/qglobal.h \
+ $(PATH_SDK_QT6)/include/QtCore/qglobal.h \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT6_INC),)
+ export PATH_SDK_QT6_INC
+ endif
+ endif
+
+ # Now for the libraries (mostly for helping out finding the KBUILD_TARGET libs).
+ ifeq ($(PATH_SDK_QT6_LIB.x86),)
+ PATH_SDK_QT6_LIB.x86 := $(patsubst %/libQt6Core$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT6)/lib32/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib32/qt6/libQt6Core$(SUFF_DLL) \
+ /usr/lib32/libQt6Core$(SUFF_DLL) \
+ /usr/lib32/qt6/libQt6Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/lib/$(type)/libQt6Core$(SUFF_DLL)) \
+ /usr/local/lib32/libQt6Core$(SUFF_DLL) \
+ /usr/local/lib32/qt6/libQt6Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).x86),/usr/local/lib/$(type)/libQt6Core$(SUFF_DLL)) \
+ $(PATH_SDK_QT6)/lib/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/qt6/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/i386-linux-gnu/libQt6Core$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT6_LIB.x86),)
+ export PATH_SDK_QT6_LIB.x86
+ endif
+ endif
+ ifeq ($(PATH_SDK_QT6_LIB.amd64),)
+ PATH_SDK_QT6_LIB.amd64 := $(patsubst %/libQt6Core$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT6)/lib64/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib64/qt6/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/amd64/libQt6Core$(SUFF_DLL) \
+ /usr/lib64/libQt6Core$(SUFF_DLL) \
+ /usr/lib64/qt6/libQt6Core$(SUFF_DLL) \
+ /usr/lib/amd64/libQt6Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/lib/$(type)/libQt6Core$(SUFF_DLL)) \
+ /usr/local/lib64/libQt6Core$(SUFF_DLL) \
+ /usr/local/lib64/qt6/libQt6Core$(SUFF_DLL) \
+ /usr/local/lib/amd64/libQt6Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).amd64),/usr/local/lib/$(type)/libQt6Core$(SUFF_DLL)) \
+ $(PATH_SDK_QT6)/lib/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/qt6/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/x86_64-linux-gnu/libQt6Core$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT6_LIB.amd64),)
+ export PATH_SDK_QT6_LIB.amd64
+ endif
+ endif
+ ifeq ($(PATH_SDK_QT6_LIB.arm64),)
+ PATH_SDK_QT6_LIB.arm64 := $(patsubst %/libQt6Core$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT6)/lib64/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib64/qt6/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/arm64/libQt6Core$(SUFF_DLL) \
+ /usr/lib64/libQt6Core$(SUFF_DLL) \
+ /usr/lib64/qt6/libQt6Core$(SUFF_DLL) \
+ /usr/lib/arm64/libQt6Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).arm64),/usr/lib/$(type)/libQt6Core$(SUFF_DLL)) \
+ /usr/local/lib64/libQt6Core$(SUFF_DLL) \
+ /usr/local/lib64/qt6/libQt6Core$(SUFF_DLL) \
+ /usr/local/lib/arm64/libQt6Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET).arm64),/usr/local/lib/$(type)/libQt6Core$(SUFF_DLL)) \
+ $(PATH_SDK_QT6)/lib/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/qt6/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/x86_64-linux-gnu/libQt6Core$(SUFF_DLL) \
+ )))
+ ifneq ($(PATH_SDK_QT6_LIB.arm64),)
+ export PATH_SDK_QT6_LIB.arm64
+ endif
+ endif
+
+ # And finally, the library path for KBUILD_TARGET.
+ ifeq ($(PATH_SDK_QT6_LIB),)
+ PATH_SDK_QT6_LIB := $(PATH_SDK_QT6_LIB.$(KBUILD_TARGET_ARCH))
+ ifeq ($(PATH_SDK_QT6_LIB),)
+ PATH_SDK_QT6_LIB := $(patsubst %/libQt6Core$(SUFF_DLL),%,$(firstword $(wildcard \
+ $(PATH_SDK_QT6)/lib/libQt6Core$(SUFF_DLL) \
+ $(PATH_SDK_QT6)/lib/qt6/libQt6Core$(SUFF_DLL) \
+ /usr/lib/libQt6Core$(SUFF_DLL) \
+ /usr/lib/qt6/libQt6Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/lib/$(type)/libQt6Core$(SUFF_DLL)) \
+ /usr/local/lib/libQt6Core$(SUFF_DLL) \
+ /usr/local/lib/qt6/libQt6Core$(SUFF_DLL) \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_TARGET_DOT_ARCH)),/usr/local/lib/$(type)/libQt6Core$(SUFF_DLL)) \
+ )))
+ endif
+ ifneq ($(PATH_SDK_QT6_LIB),)
+ export PATH_SDK_QT6_LIB
+ endif
+ endif
+
+ endif
+ endif # Unices
+ endif
+ # Found it?
+ ifeq ($(PATH_SDK_QT6),)
+ $(warning kBuild: Couldn't find the Qt6 headers and libaries...)
+ PATH_SDK_QT6 := $(KBUILD_DEVTOOLS_TRG)/qt/not-found
+ endif
+ endif
+else
+ # Resolve any fancy stuff once and for all.
+ PATH_SDK_QT6 := $(PATH_SDK_QT6)
+endif
+
+# Libraries can be in either Frameworks or lib depending on how you
+# build it on the mac. The .dmg installs into Frameworks but builds into lib.
+ifeq ($(KBUILD_TARGET),darwin)
+ ifndef PATH_SDK_QT6_LIB
+ ifneq ($(wildcard $(PATH_SDK_QT6)/Frameworks),)
+ PATH_SDK_QT6_LIB ?= $(PATH_SDK_QT6)/Frameworks
+ else
+ PATH_SDK_QT6_LIB ?= $(PATH_SDK_QT6)/lib
+ endif
+ endif
+else
+ PATH_SDK_QT6_LIB ?= $(PATH_SDK_QT6)/lib
+ PATH_SDK_QT6_INC ?= $(PATH_SDK_QT6)/include
+endif
+
+# The bits that kBuild picks up.
+# (nothing here)
+
+
+#
+# The QT6 tool.
+#
+# This is implemented here rather than in tools/QT6.kmk to enforce the global USES.
+# It also makes things easier to develop, with fewer files I mean.
+#
+TOOL_QT6 = Qt6
+
+# Tool Specific Properties
+# PATH_TOOL_QT6 - Obsolete.
+# PATH_TOOL_QT6_BIN - The path to the lrc and lupdate tools.
+# PATH_TOOL_QT6_LIBEXEC - The path to the moc, uic & rcc tools.
+# TOOL_QT6_BIN_SUFF - The binary suffix for PATH_TOOL_QT6_BIN tools.
+# TOOL_QT6_LIBEXEC_SUFF - The binary suffix for PATH_TOOL_QT6_LIBEXEC tools.
+if !defined(PATH_TOOL_QT6_BIN) && defined(PATH_TOOL_QT6)
+ PATH_TOOL_QT6_BIN := $(PATH_TOOL_QT6)/bin
+endif
+ifndef PATH_TOOL_QT6_BIN
+ PATH_TOOL_QT6_BIN := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/qt/v6*/bin)))
+ if "$(PATH_TOOL_QT6_BIN)" == "" && "$(KBUILD_DEVTOOLS_HST_ALT)" != ""
+ PATH_TOOL_QT6_BIN := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/qt/v6*/bin)))
+ endif
+ ifeq ($(PATH_TOOL_QT6_BIN),)
+ ifdef TOOL_QT6_BIN_SUFF
+ TOOL_QT6_BIN_SUFF := $(TOOL_QT6_BIN_SUFF)
+ endif
+ # Try looking for lupdate-qt6 / lupdate-$(suffix) first (this is in bin rather than libexec).
+ ifneq ($(TOOL_QT6_BIN_SUFF),)
+ PATH_TOOL_QT6_BIN := $(patsubst %/lupdate$(TOOL_QT6_BIN_SUFF),%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt6/bin/lupdate$(TOOL_QT6_BIN_SUFF)) \
+ $(if $(intersects $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES_64)),/usr/lib64/qt6/bin/lupdate$(TOOL_QT6_BIN_SUFF)) \
+ /usr/lib/qt6/bin/lupdate$(TOOL_QT6_BIN_SUFF) \
+ /usr/qt/6/bin/lupdate$(TOOL_QT6_BIN_SUFF) \
+ /usr/share/qt6/bin/lupdate$(TOOL_QT6_BIN_SUFF) \
+ /usr/local/bin/lupdate$(TOOL_QT6_BIN_SUFF) \
+ /usr/bin/lupdate$(TOOL_QT6_BIN_SUFF) \
+ )))
+ else
+ # No suffix given, so before we check out -qt6 look at qt6 specific locations to avoid choosers and symlinks.
+ PATH_TOOL_QT6_BIN := $(patsubst %/lupdate,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt6/bin/lupdate) \
+ $(if $(intersects $(KBUILD_HOST_ARCH), $(KBUILD_ARCHES_64)),/usr/lib64/qt6/bin/lupdate,) \
+ /usr/lib/qt6/bin/lupdate \
+ /usr/local/lib/qt6/bin/lupdate \
+ /usr/qt/6/bin/lupdate \
+ /usr/local/qt/6/bin/lupdate \
+ /usr/share/qt6/bin/lupdate \
+ /usr/local/share/qt6/bin/lupdate \
+ )))
+ ifeq ($(PATH_TOOL_QT6_BIN),)
+ PATH_TOOL_QT6_BIN := $(patsubst %/lupdate-qt6,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt6/bin/lupdate-qt6) \
+ $(if $(intersects $(KBUILD_HOST_ARCH), $(KBUILD_ARCHES_64)),/usr/lib64/qt6/bin/lupdate-qt6,) \
+ /usr/lib/qt6/bin/lupdate-qt6 \
+ /usr/qt/6/bin/lupdate-qt6 \
+ /usr/share/qt6/bin/lupdate-qt6 \
+ /usr/local/bin/lupdate-qt6 \
+ /usr/bin/lupdate-qt6 \
+ )))
+ ifneq ($(PATH_TOOL_QT6_BIN),)
+ TOOL_QT6_BIN_SUFF := -qt6
+ endif
+ endif
+ endif
+ # If still no go, try looking for qmake.
+ ifeq ($(PATH_TOOL_QT6_BIN),)
+ PATH_TOOL_QT6_BIN := $(patsubst %/qmake,%,$(firstword $(wildcard \
+ $(foreach type,$(KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.$(KBUILD_HOST_DOT_ARCH)),/usr/lib/$(type)/qt6/bin/qmake) \
+ $(if $(intersects $(KBUILD_HOST_ARCH), $(KBUILD_ARCHES_64)),/usr/lib64/qt6/bin/qmake,) \
+ /usr/lib/qt6/bin/qmake \
+ /usr/qt/6/bin/qmake \
+ /usr/share/qt6/bin/qmake \
+ /usr/local/bin/qmake \
+ /usr/bin/qmake \
+ )))
+ endif
+ ifneq ($(PATH_TOOL_QT6_BIN),)
+ export PATH_TOOL_QT6_BIN
+ endif
+ endif
+ # If not found, we'll enter the 'pathless' mode.
+else
+ # Resolve any fancy stuff once and for all.
+ PATH_TOOL_QT6_BIN := $(PATH_TOOL_QT6_BIN)
+endif
+
+# Unixes have moc, rcc, uic in a libexec dir rather than the bin dir, so try
+# find that directory or alias the LIBEXEC stuff onto BIN.
+ifndef PATH_TOOL_QT6_LIBEXEC
+ ifneq ($(PATH_TOOL_QT6_BIN),)
+ ifneq ($(qwildcard ,$(PATH_TOOL_QT6_BIN)/../libexec/moc*),)
+ PATH_TOOL_QT6_LIBEXEC := $(qabspath ,$(PATH_TOOL_QT6_BIN)/../libexec)
+ else
+ PATH_TOOL_QT6_LIBEXEC := $(PATH_TOOL_QT6_BIN)
+ endif
+ endif
+else
+ PATH_TOOL_QT6_LIBEXEC := $(PATH_TOOL_QT6_LIBEXEC)
+endif
+if !defined(TOOL_QT6_LIBEXEC_SUFF) && defined(PATH_TOOL_QT6_LIBEXEC)
+ ifneq ($(qwildcard ,$(PATH_TOOL_QT6_LIBEXEC)/moc-qt6$(HOSTSUFF_EXE)),)
+ TOOL_QT6_LIBEXEC_SUFF := -qt6
+ endif
+endif
+
+ifneq ($(PATH_TOOL_QT6_BIN),)
+ TOOL_QT6_MOC ?= $(PATH_TOOL_QT6_LIBEXEC)/moc$(TOOL_QT6_LIBEXEC_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT6_UIC ?= $(PATH_TOOL_QT6_LIBEXEC)/uic$(TOOL_QT6_LIBEXEC_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT6_RCC ?= $(PATH_TOOL_QT6_LIBEXEC)/rcc$(TOOL_QT6_LIBEXEC_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT6_LRC ?= $(PATH_TOOL_QT6_BIN)/lrelease$(TOOL_QT6_BIN_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT6_LUPDATE ?= $(PATH_TOOL_QT6_BIN)/lupdate$(TOOL_QT6_BIN_SUFF)$(HOSTSUFF_EXE)
+else
+ # Pathless, relies on the environment.
+ TOOL_QT6_MOC ?= moc$(TOOL_QT6_LIBEXEC_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT6_UIC ?= uic$(TOOL_QT6_LIBEXEC_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT6_RCC ?= rcc$(TOOL_QT6_LIBEXEC_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT6_LRC ?= lrelease$(TOOL_QT6_BIN_SUFF)$(HOSTSUFF_EXE)
+ TOOL_QT6_LUPDATE ?= lupdate$(TOOL_QT6_BIN_SUFF)$(HOSTSUFF_EXE)
+endif
+ifdef TOOL_QT6_USE_KSUBMIT
+ ifeq ($(KBUILD_HOST),win)
+ TOOL_QT6_MOC_KSUBMIT ?= kmk_builtin_kSubmit --$(SP)
+ endif
+endif
+
+# General Properties used by kBuild and/or units/qt.kmk
+TOOL_QT6_MOCFLAGS ?=
+TOOL_QT6_MOCINCS ?=
+TOOL_QT6_MOCDEFS ?=
+TOOL_QT6_MOCDEFS.darwin ?= __APPLE__ __GNUC__
+TOOL_QT6_MOCDEFS.solaris ?= __sun
+TOOL_QT6_MOCDEFS.win.amd64 ?= WIN64
+TOOL_QT6_MOCDEFS.win.x86 ?= WIN32
+
+
+## MOC a C++ source file.
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT6_MOC_CPP_DEPEND =
+TOOL_QT6_MOC_CPP_DEPORD =
+TOOL_QT6_MOC_CPP_OUTPUT =
+TOOL_QT6_MOC_CPP_OUTPUT_MAYBE =
+ifdef KMK_WITH_QUOTING
+ define TOOL_QT6_MOC_CPP_CMDS
+ $(QUIET)$(TOOL_QT6_MOC_KSUBMIT)$(TOOL_QT6_MOC)\
+ $(flags)\
+ $(qaddprefix sh,-I, $(incs))\
+ $(qaddprefix sh,-D, $(defs))\
+ -o $(out)\
+ $(source)
+ endef
+else
+ define TOOL_QT6_MOC_CPP_CMDS
+ $(QUIET)$(TOOL_QT6_MOC_KSUBMIT)$(TOOL_QT6_MOC)\
+ $(flags)\
+ $(addprefix -I, $(incs))\
+ $(addprefix -D, $(defs))\
+ -o $(out)\
+ $(source)
+ endef
+endif
+
+## MOC a C++ header file.
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT6_MOC_HPP_DEPEND =
+TOOL_QT6_MOC_HPP_DEPORD =
+TOOL_QT6_MOC_HPP_OUTPUT =
+TOOL_QT6_MOC_HPP_OUTPUT_MAYBE =
+ifdef KMK_WITH_QUOTING
+ define TOOL_QT6_MOC_HPP_CMDS
+ $(QUIET)$(TOOL_QT6_MOC_KSUBMIT)$(TOOL_QT6_MOC)\
+ $(flags)\
+ $(qaddprefix sh,-I, $(incs))\
+ $(qaddprefix sh,-D, $(defs))\
+ -o $(out)\
+ $(source)
+ endef
+else
+ define TOOL_QT6_MOC_HPP_CMDS
+ $(QUIET)$(TOOL_QT6_MOC_KSUBMIT)$(TOOL_QT6_MOC)\
+ $(flags)\
+ $(addprefix -I, $(incs))\
+ $(addprefix -D, $(defs))\
+ -o $(out)\
+ $(source)
+ endef
+endif
+
+## Compile a Qt user interface file (.ui).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT6_UIC_UI_DEPEND =
+TOOL_QT6_UIC_UI_DEPORD =
+TOOL_QT6_UIC_UI_OUTPUT =
+TOOL_QT6_UIC_UI_OUTPUT_MAYBE =
+define TOOL_QT6_UIC_UI_CMDS
+ $(QUIET)$(TOOL_QT6_UIC)\
+ $(flags)\
+ -o $(out)\
+ $(source)
+endef
+
+## Compile a Qt resource file (.qrc).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+# @remarks The sed script generating the dependency file is a bit naive.
+TOOL_QT6_RCC_QRC_DEPEND =
+TOOL_QT6_RCC_QRC_DEPORD =
+TOOL_QT6_RCC_QRC_OUTPUT =
+TOOL_QT6_RCC_QRC_OUTPUT_MAYBE =
+define TOOL_QT6_RCC_QRC_CMDS
+ $(QUIET)$(TOOL_QT6_RCC)\
+ $(flags)\
+ -o $(out)\
+ $(source)
+ $(QUIET2)$(APPEND) -n $(dep) '\' \
+ '$(out): \' \
+ '$(source) \'
+ $(QUIET2)$(SED) \
+ -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
+ -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
+ -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
+ -e 's|$$$$| \\|' \
+ --append $(dep) \
+ $(source)
+ $(QUIET2)$(APPEND) $(dep)
+ $(QUIET2)$(SED) \
+ -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
+ -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
+ -e 's|^[^/][^:]|$(abspathex $(dir $(source)),$(defpath))/&|' \
+ -e 's|$$$$|:\n|' \
+ --append $(dep) \
+ $(source)
+ $(QUIET2)$(APPEND) $(dep)
+endef
+
+## Compile a Qt translation file (.ts).
+# @param $(target) Normalized main target name.
+# @param $(source) Source filename (relative).
+# @param $(out) Object file name. This shall be (re)created by the compilation.
+# @param $(dep) Dependcy file. This may be (re)created by the compilation.
+# @param $(flags) Flags.
+# @param $(defs) Definitions.
+# @param $(incs) Includes.
+# @param $(outbase) Output basename (full). Use this for list files and such.
+#
+TOOL_QT6_LRC_TS_DEPEND =
+TOOL_QT6_LRC_TS_DEPORD =
+TOOL_QT6_LRC_TS_OUTPUT =
+TOOL_QT6_LRC_TS_OUTPUT_MAYBE =
+define TOOL_QT6_LRC_TS_CMDS
+ $(QUIET)$(TOOL_QT6_LRC)\
+ $(flags)\
+ $(source)\
+ -qm $(out)
+endef
+
+
+
+#
+#
+# Back to the Qt6 unit.
+#
+#
+
+
+## wrapper for the lrelease (LRC) command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT6_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT6_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT6_LRC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt6_target_pre_handle_translation helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt6_target_pre_handle_translation_dx
+
+$(out) + $(more_output) +| $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT6_LRC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT6_LRC_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT6_LRC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_CLEAN += $(out) $(more_output) $(maybe_output) $(dep)
+$(target)-inst-nls_SOURCES += $(out)
+
+endef # def_unit_qt6_target_pre_handle_translation_dx
+
+##
+# Handle a source file listed in QT_TRANSLATIONS.
+#
+# The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
+# to be translated into .qm files that are loadble by Qt.
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt6_target_pre_handle_translation
+local type := LRC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
+local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
+local out := $(outbase).qm
+local dep := $(out).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_LRC_TS_CMDS
+ $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
+local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
+local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt6_target_pre_handle_translation_dx))
+
+endef # def_unit_qt6_target_pre_handle_translation
+
+
+
+## wrapper for the UIC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT6_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT6_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT6_RCC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt6_target_pre_handle_qrc helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt6_target_pre_handle_rcc_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT6_RCC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT6_RCC_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT6_RCC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_GEN_SOURCES_ += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef # def_unit_qt6_target_pre_handle_rcc_dx
+
+##
+# Source handler for .qrc sources (Qt resource files).
+#
+# @remarks $(evalvalctx me).
+define def_unit_qt6_src_handler_qrc
+local type := RCC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
+local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.gen.cpp
+local realout := $(outbase).gen.cpp
+local dep := $(realout).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_RCC_QRC_CMDS
+ $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
+local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
+local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt6_target_pre_handle_rcc_dx))
+
+endef # def_unit_qt6_src_handler_qrc
+
+
+
+## wrapper for the UIC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT6_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT6_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT6_UIC_CMDS_DEP =
+endif
+
+##
+# def_unit_qt6_src_handler_ui helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt6_target_pre_handle_ui_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT6_UIC_CMDS_DEP) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT6_UIC_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT6_UIC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef # def_unit_qt6_target_pre_handle_ui_dx
+
+##
+# Source handler for .ui sources.
+#
+# @remarks $(evalvalctx me).
+define def_unit_qt6_src_handler_ui
+local type := UIC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local qtuicdir := $($(target)_0_OUTDIR)/qtuic
+local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.gen.h
+local realout := $(outbase).gen.h
+local dep := $(realout).dep
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_UIC_UI_CMDS
+ $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
+local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
+local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt6_target_pre_handle_ui_dx))
+
+endef # def_unit_qt6_src_handler_ui
+
+
+
+## wrapper for the MOC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT6_MOC_HPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT6_MOC_HPP_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT6_MOC_HPP_CMDS_DEP =
+endif
+
+##
+# def_unit_qt6_target_pre_handle_moc_hdr helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt6_target_pre_handle_moc_hdr_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT6_MOC_HPP_CMDS_DEP) \
+ | \
+ $(orderdeps) $(my_target_intermediate_vars)
+ %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT6_MOC_HPP_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT6_MOC_HPP_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_GEN_SOURCES_ += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef
+
+##
+# Handle a source file listed in QT_MOCHDRS.
+#
+# The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
+# generate a .cpp file for each of them and add it to the generated
+# sources so that it's compiled and linked. (There is an alternative
+# way to do this where the .cpp file is included, this isn't currently
+# supported by this unit.)
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt6_target_pre_handle_moc_hdr
+local type := MOC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.cpp
+local realout := $(outbase).cpp
+local dep := $(realout).dep
+local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
+local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_MOC_HPP_CMDS
+ $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
+local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
+local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt6_target_pre_handle_moc_hdr_dx))
+
+endef # def_unit_qt6_target_pre_handle_moc_hdr
+
+
+## wrapper for the MOC command dependencies.
+ifndef NO_COMPILE_CMDS_DEPS
+ _UNIT_QT6_MOC_CPP_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT6_MOC_CPP_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _UNIT_QT6_MOC_CPP_CMDS_DEP =
+endif
+
+##
+# def_unit_qt6_target_pre_handle_moc_src helper that is expanded before evaluation.
+#
+# This is necessary to resolve reference to local variables before doing
+# assignments and setting up commands. They would otherwise be resolved
+# later in a different context and the result would be completely wrong.
+#
+define def_unit_qt6_target_pre_handle_moc_src_dx
+
+$(out) +| $(realout) $(more_output) $(maybe_output): \
+ $(deps) \
+ $(value _UNIT_QT6_MOC_CPP_CMDS_DEP) \
+ | \
+ $(orderdeps) $(my_target_intermediate_vars)
+ %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
+ $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
+
+$(cmds)
+
+ $(QUIET)$(CP) --changed -f $(out) $(realout)
+ifndef NO_COMPILE_CMDS_DEPS
+ifdef KBUILD_HAVE_OPTIMIZED_APPEND
+ %$$(QUIET2)$$(APPEND) -ni '$(dep)' \
+ 'define $(target)_$(subst :,_,$(source))_QT6_MOC_CPP_CMDS_PREV_' \
+ '--insert-command=$(out)' \
+ 'endef'
+else
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT6_MOC_CPP_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+endif
+
+$(target)_2_INTERMEDIATES += $(realout)
+$(target)_CLEAN += $(out) $(realout) $(more_output) $(maybe_output) $(dep)
+
+endef
+
+##
+# Handle a source file listed in QT_MOCSRCS.
+#
+# The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
+# a .moc file that we're expected to generate here.
+#
+# @remarks Invoked via $(evalvalctx ).
+define def_unit_qt6_target_pre_handle_moc_src
+local type := MOC
+
+# fetch the properties.
+local tool := $(kb-src-tool dummy_var)
+local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
+local out := $(outbase).tmp.moc
+local realout := $(outbase).moc
+local dep := $(realout).dep
+local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
+local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
+local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
+local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
+local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
+
+# default path + source dep.
+ifneq ($(defpath),)
+ ifdef KMK_WITH_QUOTING
+local source := $(qabspathex ,$(source),$(defpath))
+local deps := $(qabspathex ,$(deps),$(defpath)) $(source)
+local incs := $(qabspathex ,$(incs),$(defpath))
+ else
+local source := $(abspathex $(source),$(defpath))
+local deps := $(abspathex $(deps),$(defpath)) $(source)
+local incs := $(abspathex $(incs),$(defpath))
+ endif
+else
+local deps += $(source)
+endif
+
+# call the tool
+ifndef TOOL_$(tool)_MOC_CPP_CMDS
+ $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
+endif
+local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
+local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
+local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
+local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
+
+# generate the link rule and update some source and target variables.
+ifndef NO_COMPILE_CMDS_DEPS
+ $(eval includedep $(dep))
+endif
+$(eval $(def_unit_qt6_target_pre_handle_moc_src_dx))
+
+endef # def_unit_qt6_target_pre_handle_moc_src
+
+
+##
+# Adds sources containing Q_OBJECT to QT_MOCSRCS.
+define def_unit_qt6_target_pre_cpp_source
+ifneq ($(file-size $(source)),-1)
+ ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
+ $(eval $(target)_QT_MOCSRCS += $(source))
+ endif
+endif
+endef # def_unit_qt6_target_pre_cpp_source
+
+##
+# Invoked early in the processing of a target that uses the Qt unit.
+#
+# It will append the qt source handlers to the target (.h, .ui, .ts,
+# .png, .bmp, .gif).
+#
+# It will then check all the C++ sources and check which needs
+# a .moc files and generate rules and dependencies fofor these
+#
+define def_unit_qt6_target_pre
+
+# Make QTTOOL the default for the specific Qt tools instead of TOOL.
+ifneq ($($(target)_QTTOOL),)
+ ifeq ($($(target)_MOCTOOL),)
+ $(target)_MOCTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_UICTOOL),)
+ $(target)_UICTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_RCCTOOL),)
+ $(target)_RCCTOOL := $($(target)_QTTOOL)
+ endif
+ ifeq ($($(target)_LRCTOOL),)
+ $(target)_LRCTOOL := $($(target)_QTTOOL)
+ endif
+endif
+
+# Deal with QT_MODULES, QT_PREFIX and QT_INFIX.
+local qt_modules := \
+ $($(target)_QT_MODULES.$(bld_trg)) \
+ $($(target)_QT_MODULES.$(bld_trg_arch)) \
+ $($(target)_QT_MODULES.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MODULES.$(bld_trg_cpu)) \
+ $($(target)_QT_MODULES.$(bld_type)) \
+ $($(target)_QT_MODULES)
+local qt_prefix := $(firstword \
+ $($(target)_QT_PREFIX.$(bld_trg)) \
+ $($(target)_QT_PREFIX.$(bld_trg_arch)) \
+ $($(target)_QT_PREFIX.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_PREFIX.$(bld_trg_cpu)) \
+ $($(target)_QT_PREFIX.$(bld_type)) \
+ $($(target)_QT_PREFIX))
+local qt_infix := $(firstword \
+ $($(target)_QT_INFIX.$(bld_trg)) \
+ $($(target)_QT_INFIX.$(bld_trg_arch)) \
+ $($(target)_QT_INFIX.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_INFIX.$(bld_trg_cpu)) \
+ $($(target)_QT_INFIX.$(bld_type)) \
+ $($(target)_QT_INFIX))
+ifeq ($(bld_trg),darwin)
+ # Adding -F to CXXFLAGS is necessary to make #include <QtCore/qstring.h> stuff work...
+ $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT6_LIB) )
+ $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT6_LIB) )
+ $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT6_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) )
+ $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT6_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/A/Headers) )
+else
+ ifeq ($(bld_trg),win)
+ $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT6_LIB)/$(qt_prefix)Qt6$(module)$(qt_infix)$(SUFF_LIB)) )
+ ifeq ($(tool_do),LINK_PROGRAM)
+ $(eval $(target)_LIBS += $(PATH_SDK_QT6_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) )
+ endif
+ else
+ $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT6_LIB)/lib$(qt_prefix)Qt6$(module)$(qt_infix)$(SUFF_DLL)) )
+ endif
+ $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT6_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT6_INC) )
+endif
+$(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) )
+
+
+# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
+# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
+ifndef $(target)_QT_MOCSRCS
+ $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
+ $($(target)_SOURCES.$(bld_trg)) \
+ $($(target)_SOURCES.$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_SOURCES.$(bld_trg_cpu)) \
+ $($(target)_SOURCES.$(bld_type)) \
+ $($(target)_SOURCES) \
+ ), $(evalval def_unit_qt6_target_pre_cpp_source))
+endif
+
+# Install source handlers for .ui files.
+$(target)_SRC_HANDLERS += \
+ .ui:def_unit_qt6_src_handler_ui \
+ .UI:def_unit_qt6_src_handler_ui \
+ .qrc:def_unit_qt6_src_handler_qrc \
+ .qrc:def_unit_qt6_src_handler_qrc
+
+# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
+local qtmocdir := $($(target)_0_OUTDIR)/qtmoc
+local qtuicdir := $($(target)_0_OUTDIR)/qtuic
+local qtrccdir := $($(target)_0_OUTDIR)/qtrcc
+local qtnlsdir := $($(target)_0_OUTDIR)/qtnls
+$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
+$(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
+
+# Since we add a lot of stuff to 2_INTERMEDIATES, we must exclude it from the intermediates
+# used by the rules we generate to avoid circular dependencies.
+local my_target_intermediate_vars := $(filter-out %_2_INTERMEDIATES$(CLOSEPAR),$(target_intermediate_vars))
+
+# Deal with QT_MOCSRCS.
+$(foreach source, \
+ $($(target)_QT_MOCSRCS.$(bld_trg)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg_arch)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MOCSRCS.$(bld_trg_cpu)) \
+ $($(target)_QT_MOCSRCS.$(bld_type)) \
+ $($(target)_QT_MOCSRCS) \
+ , $(evalvalctx def_unit_qt6_target_pre_handle_moc_src))
+
+# Deal with QT_MOCHDRS.
+$(foreach source, \
+ $($(target)_QT_MOCHDRS.$(bld_trg)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg_arch)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_MOCHDRS.$(bld_trg_cpu)) \
+ $($(target)_QT_MOCHDRS.$(bld_type)) \
+ $($(target)_QT_MOCHDRS) \
+ , $(evalvalctx def_unit_qt6_target_pre_handle_moc_hdr))
+
+# Deal with QT_TRANSLATIONS.
+# ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
+local translations := \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg_arch)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg).$(bld_trg_arch)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_trg_cpu)) \
+ $($(target)_QT_TRANSLATIONS.$(bld_type)) \
+ $($(target)_QT_TRANSLATIONS)
+ifneq ($(strip $(translations)),)
+ local expr := _ALL_INSTALLS_IMPLICIT += $(target)-inst-nls
+ $(eval $(expr))
+ ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
+ $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
+ else
+ $(target)-inst-nls_MODE := 0644
+ endif
+ ifdef $(target)_QT_TRANSLATIONS_INST
+ $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
+ endif
+ $(target)-inst-nls_SOURCES :=
+ $(foreach source, $(translations)\
+ , $(evalvalctx def_unit_qt6_target_pre_handle_translation))
+endif
+
+endef # def_unit_qt6_target_pre
+
+
+#
+# Rule for debugging.
+#
+unit-qt6-show-vars:
+ @$(ECHO) 'The Qt6 SDK variables:'
+ @$(ECHO) ' PATH_SDK_QT6 = "$(PATH_SDK_QT6)"'
+ @$(ECHO) ' PATH_SDK_QT6_INC = "$(PATH_SDK_QT6_INC)"'
+ @$(ECHO) ' PATH_SDK_QT6_LIB = "$(PATH_SDK_QT6_LIB)"'
+ @$(ECHO) ' PATH_SDK_QT6_LIB.amd64 = "$(PATH_SDK_QT6_LIB.amd64)"'
+ @$(ECHO) ' PATH_SDK_QT6_LIB.x86 = "$(PATH_SDK_QT6_LIB.x86)"'
+ @$(ECHO) 'The Qt6 TOOL variables:'
+ @$(ECHO) ' PATH_TOOL_QT6_BIN = "$(PATH_TOOL_QT6_BIN)"'
+ @$(ECHO) ' PATH_TOOL_QT6_LIBEXEC = "$(PATH_TOOL_QT6_LIBEXEC)"'
+ @$(ECHO) ' TOOL_QT6_BIN_SUFF = "$(TOOL_QT6_BIN_SUFF)"'
+ @$(ECHO) ' TOOL_QT6_LIBEXEC_SUFF = "$(TOOL_QT6_LIBEXEC_SUFF)"'
+ @$(ECHO) ' TOOL_QT6_MOC = "$(TOOL_QT6_MOC)"'
+ @$(ECHO) ' TOOL_QT6_UIC = "$(TOOL_QT6_UIC)"'
+ @$(ECHO) ' TOOL_QT6_RCC = "$(TOOL_QT6_RCC)"'
+ @$(ECHO) ' TOOL_QT6_LRC = "$(TOOL_QT6_LRC)"'
+ @$(ECHO) ' TOOL_QT6_LUPDATE = "$(TOOL_QT6_LUPDATE)"'
+
diff --git a/kBuild/units/vccprecomp.kmk b/kBuild/units/vccprecomp.kmk
new file mode 100644
index 0000000..5f21d10
--- /dev/null
+++ b/kBuild/units/vccprecomp.kmk
@@ -0,0 +1,66 @@
+# $Id: vccprecomp.kmk 3415 2020-08-20 23:43:33Z bird $
+## @file
+# kBuild Unit - Target Level Precompiled Headers for Visual C++.
+#
+
+#
+# Copyright (c) 2016-2019 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+
+UNIT_vccprecomp = Target level precompiled Headers for Visual C++
+
+#
+# Early target processing pass #1.
+#
+# This set the internal _VCC_PCH_FILE and VCC_COMMON_OBJ_PDB properties,
+# which will be picked up by the VCCxxx tool.
+#
+define def_unit_vccprecomp_target_pre
+ $(target)_1_VCC_PCH_FILE := $(outbase)-pch.pch
+ $(target)_1_VCC_COMMON_OBJ_PDB := $(outbase)-common-obj.pdb
+endef
+
+#
+# Early target processing pass #2.
+#
+# This sets up a rule for creating the .pch file after qt5 and similar units
+# are done modifying INCS, DEFS and company. The '-PCH' variant of the VCC
+# tool, is defined together with $(pchtool) and allow us to bypass the options
+# and dependencies triggered by _1_VCC_PCH_FILE, _1_VCC_COMMON_OBJ_PDB and
+# _PCH_HDR, and also make sure we don't get circular dependencies by way of
+# kDepObj and the debug info.
+#
+define def_unit_vccprecomp_target_pre_2
+ local pchtool := $(call _TARGET_TOOL,$(target),PCH)
+ local source := $($(target)_PCH_HDR)
+ $(source)_TOOL := $(pchtool)-PCH
+ local suff := $(suffix $(source))
+ local type := CXX
+ $(kb-src-one 4)
+endef
+
diff --git a/kBuild/units/yacc.kmk b/kBuild/units/yacc.kmk
new file mode 100644
index 0000000..e4bb8cc
--- /dev/null
+++ b/kBuild/units/yacc.kmk
@@ -0,0 +1,198 @@
+# $Id: yacc.kmk 3284 2019-01-05 01:40:31Z bird $
+## @file
+# yacc/bison unit.
+#
+
+#
+# Copyright (c) 2008-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+# As a special exception you are granted permission to include this file, via
+# the kmk include directive, as you wish without this in itself causing the
+# resulting makefile, program or whatever to be covered by the GPL license.
+# This exception does not however invalidate any other reasons why the makefile,
+# program, whatever should not be covered the GPL.
+#
+#
+
+ifdef UNIT_yacc
+ $(error kBuild: The yacc unit was included twice!)
+endif
+UNIT_yacc = yacc
+
+# Add our target properties.
+PROPS_TOOLS += YACCTOOL
+PROPS_SINGLE += YACCTOOL
+PROPS_ACCUMULATE_R += YACCFLAGS
+
+# Add ourselves to the default source handlers.
+KBUILD_SRC_HANDLERS += \
+ .y:def_src_handler_yacc_y \
+ .ypp:def_src_handler_yacc_ypp \
+ .y++:def_src_handler_yacc_ypp
+
+
+## wrapper the compile command dependency check.
+ifndef NO_COMPILE_CMDS_DEPS
+ _DEP_YACC_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_YACC_CMDS_PREV_),$$(commands $(out)),FORCE)
+else
+ _DEP_YACC_CMDS =
+endif
+
+
+##
+# Generates the rules for running flex on a specific source file.
+#
+# @param $(obj) The object file.
+# @param lots more
+define def_yacc_rule
+$(out) + $(output_extra) +| $(output_maybe) : \
+ $(deps) \
+ $(value _DEP_YACC_CMDS) \
+ | \
+ $(orderdeps)
+ %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
+ $$(QUIET)$$(RM) -f -- $(dep) $(out) $(output_extra) $(output_maybe)
+
+$(cmds)
+
+ifndef NO_COMPILE_CMDS_DEPS
+ %$$(QUIET2)$$(APPEND) '$(dep)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_YACC_CMDS_PREV_'
+ %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
+ %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
+endif
+
+# update globals and target properties.
+_OUT_FILES += $(out) $(output_extra) $(output_maybe)
+$(target)_GEN_SOURCES_ += $(out)
+$(target)_2_INTERMEDIATES += $(intermediates)
+
+endef # def_yacc_rule
+
+
+##
+# Handler for .y files listed in the SOURCES properties.
+#
+# .y files are transformed into .c (and maybe .h) files that then gets
+# compiled by the C compiler.
+#
+# @param target The target file.
+# @param source The source file.
+# @param lots more
+# @returns quite a bit.
+#
+define def_src_handler_yacc_y
+# Figure out all the props.
+local type := YACC
+local tmp := $(kb-src-tool tool)
+ifeq ($(tool),)
+$(error kBuild: $(target) / $(sources) does not a (yacc) tool defined!)
+endif
+ifndef TOOL_$(tool)_YACC_CMDS
+$(error kBuild: TOOL_$(tool)_YACC_CMDS isn't defined! target=$(target) source=$(source) )
+endif
+local out := $(kb-obj-base outbase).c
+local tmp := $(kb-src-prop YACCFLAGS,flags,left-to-right,)
+local tmp := $(kb-src-prop DEPS,deps,left-to-right,$(defpath))
+local tmp := $(kb-src-prop ORDERDEPS,orderdeps,left-to-right,$(defpath))
+local dirdep := $(call DIRDEP,$(dir $(out)))
+
+# Adjust paths if we got a default path.
+ifneq ($(defpath),)
+ local source := $(abspathex $(source),$(defpath))
+endif
+
+# dependency file.
+local dep := $(out)$(SUFF_DEP)
+ifndef NO_COMPILE_CMDS_DEPS
+ _DEPFILES_INCLUDED += $(dep)
+ $(eval includedep $(dep))
+endif
+
+# Call the tool.
+local cmds := $(TOOL_$(tool)_YACC_CMDS)
+local output_extra := $(TOOL_$(tool)_YACC_OUTPUT)
+local output_maybe := $(TOOL_$(tool)_YACC_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_YACC_DEPEND) $(source)
+local orderdeps += $(TOOL_$(tool)_YACC_DEPORD) $(dirdep)
+
+# Whether it generates a header file depends on flags.
+local intermediates := $(filter %.h %.hpp %.h++ %.H,$(output_extra))
+
+# Generate the rule.
+$(eval $(def_yacc_rule))
+
+endef # def_src_handler_yacc_y
+
+
+##
+# Handler for .ypp/.y++ files listed in the SOURCES properties.
+#
+# .ypp/++ files are transformed into .cpp/++ (and maybe .hpp/++) files that then gets
+# compiled by the C++ compiler.
+#
+# @param target The target file.
+# @param source The source file.
+# @param lots more
+# @returns quite a bit.
+#
+define def_src_handler_yacc_ypp
+# Figure out all the props.
+local type := YACC
+local tmp := $(kb-src-tool tool)
+ifeq ($(tool),)
+$(error kBuild: $(target) / $(sources) does not a (yacc) tool defined!)
+endif
+ifndef TOOL_$(tool)_YACC_CMDS
+$(error kBuild: TOOL_$(tool)_YACC_CMDS isn't defined! target=$(target) source=$(source) )
+endif
+local out := $(kb-obj-base outbase).c$(substr $(suffix $(source),3))
+local tmp := $(kb-src-prop YACCFLAGS,flags,left-to-right,)
+local tmp := $(kb-src-prop DEPS,deps,left-to-right,$(defpath))
+local tmp := $(kb-src-prop ORDERDEPS,orderdeps,left-to-right,$(defpath))
+local dirdep := $(call DIRDEP,$(dir $(out)))
+
+# Adjust paths if we got a default path.
+ifneq ($(defpath),)
+ local source := $(abspathex $(source),$(defpath))
+endif
+
+# dependency file.
+local dep := $(out)$(SUFF_DEP)
+ifndef NO_COMPILE_CMDS_DEPS
+ _DEPFILES_INCLUDED += $(dep)
+ $(eval includedep $(dep))
+endif
+
+# Call the tool.
+local cmds := $(TOOL_$(tool)_YACC_CMDS)
+local output_extra := $(TOOL_$(tool)_YACC_OUTPUT)
+local output_maybe := $(TOOL_$(tool)_YACC_OUTPUT_MAYBE)
+local deps += $(TOOL_$(tool)_YACC_DEPEND) $(source)
+local orderdeps += $(TOOL_$(tool)_YACC_DEPORD) $(dirdep)
+
+# Whether it generates a header file depends on flags.
+local intermediates := $(filter %.h %.hpp %.h++ %.H,$(output_extra))
+
+# Generate the rule.
+$(eval $(def_yacc_rule))
+
+endef # def_src_handler_yacc_ypp
+