Commit 9f64cd5c authored by Gianfranco Costamagna's avatar Gianfranco Costamagna

New upstream version 0.1.9998svn3290+dfsg

parent 4e5caae5
# $Id: footer-pass2-compiling-targets.kmk 3160 2018-03-19 22:39:19Z bird $
# $Id: footer-pass2-compiling-targets.kmk 3285 2019-01-05 03:24:58Z bird $
## @file
# kBuild - Footer - Target lists - Pass 2 - Compiling Targets.
#
#
# Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
# Copyright (c) 2004-2019 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
#
# This file is part of kBuild.
#
......@@ -36,7 +36,79 @@
# Object processing.
#
## wrapper the compile command dependency check.
ifndef NO_COMPILE_CMDS_DEPS
## Generates the rules for building a specific object and the aliases.
# for building a source file.
# @param $(obj) The object file.
define def_target_source_rule_v3plus
$$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
$$(obj) + $$(kbsrc_output) +| $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars)
%$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
$$(QUIET)$$(RM) -f -- $(dep) $(obj) $(kbsrc_output) $(kbsrc_output_maybe)
endif
$(kbsrc_cmds)
%$$(QUIET2)$$(APPEND) -in '$(dep)' '' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_' '--insert-command=$(obj)' 'endef'
$$(basename $$(notdir $$(obj))).o: $$(obj)
endef # def_target_source_rule_v3plus
## Generates the rules for building a specific object and the aliases, kObjCache variant.
# for building a source file.
# @param $(obj) The object file.
define def_target_source_rule_v3plus_objcache
$$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
_OUT_FILES += $(outbase).koc
$$(outbase).koc +| $$(obj) $$(kbsrc_output) $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars)
%$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
$(kbsrc_cmds)
%$$(QUIET2)$$(APPEND) -in '$(dep)' '' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_' '--insert-command=$(obj)' 'endef'
$$(basename $$(notdir $$(obj))).o: $$(obj)
endef # def_target_source_rule_v3plus_objcache
else # NO_COMPILE_CMDS_DEPS
## Generates the rules for building a specific object and the aliases.
# for building a source file.
# @param $(obj) The object file.
define def_target_source_rule_v3plus
$$(obj) + $$(kbsrc_output) +| $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars)
%$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
$$(QUIET)$$(RM) -f -- $(dep) $(obj) $(kbsrc_output) $(kbsrc_output_maybe)
endif
$(kbsrc_cmds)
$$(basename $$(notdir $$(obj))).o: $$(obj)
endef # def_target_source_rule_v3plus
## Generates the rules for building a specific object and the aliases, kObjCache variant.
# for building a source file.
# @param $(obj) The object file.
define def_target_source_rule_v3plus_objcache
_OUT_FILES += $(outbase).koc
$$(outbase).koc +| $$(obj) $$(kbsrc_output) $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars)
%$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
$(kbsrc_cmds)
$$(basename $$(notdir $$(obj))).o: $$(obj)
endef # def_target_source_rule_v3plus_objcache
endif # NO_COMPILE_CMDS_DEPS
$(eval-opt-var def_target_source_rule_v3plus)
$(eval-opt-var def_target_source_rule_v3plus_objcache)
##
## Legacy legacy legacy - start
##
## Wrapper
ifndef NO_COMPILE_CMDS_DEPS
if1of ($(KMK_FEATURES),dot-must-make)
_DEP_COMPILE_CMDS =
......@@ -48,40 +120,23 @@ else
_DEP_COMPILE_CMDS =
endif
## Generates the rules for building a specific object, and the aliases
## Generates the rules for building a specific object, and the aliases - legacy version.
# for building a source file.
# @param $(obj) The object file.
define def_target_source_rule
ifndef NO_COMPILE_CMDS_DEPS
$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
endif
ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE
ifneq ($(TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE),)
_OUT_FILES += $(outbase).koc
$(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
$($(target)_$(source)_DEPEND_) \
$(value _DEP_COMPILE_CMDS) \
| \
$($(target)_$(source)_DEPORD_) \
$$$$($(target)_INTERMEDIATES) \
$$$$($(target)_INTERMEDIATES.$(bld_trg)) \
$$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
$$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
$$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
$$$$($(target)_INTERMEDIATES.$(bld_type))
$($(target)_$(source)_DEPEND_) $(value _DEP_COMPILE_CMDS) \
| $($(target)_$(source)_DEPORD_) $(target_intermediate_vars)
%$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
else
$(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
$($(target)_$(source)_DEPEND_) \
$(value _DEP_COMPILE_CMDS) \
| \
$($(target)_$(source)_DEPORD_) \
$$$$($(target)_INTERMEDIATES) \
$$$$($(target)_INTERMEDIATES.$(bld_trg)) \
$$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
$$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
$$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
$$$$($(target)_INTERMEDIATES.$(bld_type))
$($(target)_$(source)_DEPEND_) $(value _DEP_COMPILE_CMDS) \
| $($(target)_$(source)_DEPORD_) $(target_intermediate_vars)
%$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
$$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
......@@ -105,7 +160,6 @@ ifndef NO_COMPILE_CMDS_DEPS
endif
$(basename $(notdir $(obj))).o: $(obj)
$(basename $(notdir $(obj))).obj: $(obj)
## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added.
$(target)_$(source)_CMDS_ :=
......@@ -115,6 +169,9 @@ $(target)_$(source)_DEPEND_ :=
$(target)_$(source)_DEPORD_ :=
endef # def_target_source_rule
$(eval-opt-var def_target_source_rule)
##
## Legacy legacy legacy - end
## wrapper the link command dependency check.
......@@ -212,32 +269,32 @@ endef
# @{
define def_src_handler_c
local type := C
$(kb-src-one 2)
$(kb-src-one 3)
endef
define def_src_handler_cxx
local type := CXX
$(kb-src-one 2)
$(kb-src-one 3)
endef
define def_src_handler_objc
local type := OBJC
$(kb-src-one 2)
$(kb-src-one 3)
endef
define def_src_handler_objcxx
local type := OBJCXX
$(kb-src-one 2)
$(kb-src-one 3)
endef
define def_src_handler_asm
local type := AS
$(kb-src-one 2)
$(kb-src-one 3)
endef
define def_src_handler_rc
local type := RC
$(kb-src-one 2)
$(kb-src-one 3)
endef
define def_src_handler_obj
......@@ -488,6 +545,27 @@ $(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)
# no local here - must be writable across some foreachs.
othersrc :=
$(target)_2_OBJS :=
$(target)_2_INTERMEDIATES =
# kObjCache.
ifdef KBUILD_USE_KOBJCACHE
ifneq ($($(target)_KOBJCACHE),)
local use_objcache := 1
else
local use_objcache :=
endif
local use_objcache :=
endif
# Target level intermediates (before units!).
local target_intermediate_vars := $$$$($(target)_2_INTERMEDIATES) $(foreach var, \
$(target)_INTERMEDIATES \
$(target)_INTERMEDIATES.$(bld_trg) \
$(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch) \
$(target)_INTERMEDIATES.$(bld_trg_arch) \
$(target)_INTERMEDIATES.$(bld_trg_cpu) \
$(target)_INTERMEDIATES.$(bld_type) \
,$(if-expr defined($(var)),$$$$($(var)),))
# Do units pre source callouts.
local units := \
......@@ -693,6 +771,27 @@ endif
# no local here - must be writable across some foreachs.
othersrc :=
$(target)_2_OBJS :=
$(target)_2_INTERMEDIATES =
# kObjCache.
ifdef KBUILD_USE_KOBJCACHE
ifneq ($($(target)_KOBJCACHE),)
local use_objcache := 1
else
local use_objcache :=
endif
local use_objcache :=
endif
# Target level intermediates (before units!).
local target_intermediate_vars := $$$$($(target)_2_INTERMEDIATES) $(foreach var, \
$(target)_INTERMEDIATES \
$(target)_INTERMEDIATES.$(bld_trg) \
$(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch) \
$(target)_INTERMEDIATES.$(bld_trg_arch) \
$(target)_INTERMEDIATES.$(bld_trg_cpu) \
$(target)_INTERMEDIATES.$(bld_type) \
,$(if-expr defined($(var)),$$$$($(var)),))
# Do units pre source callouts.
local units := \
......
# $Id: header.kmk 3166 2018-03-20 12:42:52Z bird $
# $Id: header.kmk 3253 2019-01-02 00:23:15Z bird $
## @file
# kBuild - File included at top of a makefile.
#
......@@ -79,7 +79,7 @@ endif
# The revision in which this file was last modified.
# This can be useful when using development versions of kBuild.
#
KMK_REVISION := $(patsubst %:,, $Rev: 3166 $ )
KMK_REVISION := $(patsubst %:,, $Rev: 3253 $ )
#
......@@ -1089,15 +1089,15 @@ KBUILD_SRC_HANDLERS := \
## PROPS_TOOLS
# This is a subset of PROPS_SINGLE.
PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL OBJCXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
PROPS_TOOLS := TOOL CTOOL CXXTOOL PCHTOOL OBJCTOOL OBJCXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
## PROPS_SINGLE
# The list of non-accumulative target properties.
# A Config.kmk file can add it's own properties to this list and kBuild
# will do the necessary inheritance for templates, sdks, tools and targets.
PROPS_SINGLE := $(PROPS_TOOLS) TEMPLATE INSTTYPE INST STAGE NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \
OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF OBJCXXOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF BINSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \
MODE UID GID LD_DEBUG DEBUG_INSTTYPE DEBUG_INST DEBUG_STAGE
OBJSUFF COBJSUFF CXXOBJSUFF PCHOBJSUFF OBJCOBJSUFF OBJCXXOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF BINSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \
MODE UID GID LD_DEBUG DEBUG_INSTTYPE DEBUG_INST DEBUG_STAGE PCH_HDR
## PROPS_SINGLE_LNK
# Subset of PROPS_SINGLE which applies to all linkable targets.
PROPS_SINGLE_LNK := $(filter-out FETCHTOOL UNPACKTOOL PATCHTOOL FETCHDIR, $(PROPS_SINGLE))
......@@ -1119,6 +1119,7 @@ PROPS_ACCUMULATE_R := \
ARFLAGS \
CFLAGS CDEFS \
CXXFLAGS CXXDEFS \
PCHFLAGS PCHDEFS \
OBJCFLAGS OBJCDEFS \
OBJCXXFLAGS OBJCXXDEFS \
ASFLAGS ASDEFS \
......@@ -1137,7 +1138,7 @@ PROPS_ACCUMULATE_R_LNK := $(filter-out ARFLAGS LDFLAGS EXEC_IFFLAGS FETCHFLAGS U
# will do the necessary inheritance from templates to targets.
PROPS_ACCUMULATE_L := \
SDKS USES SOURCES EXEC_SOURCES SRC_HANDLERS INTERMEDIATES \
INCS CINCS CXXINCS OBJCINCS OBJCXXINCS ASINCS RCINCS \
INCS CINCS CXXINCS PCHINCS OBJCINCS OBJCXXINCS ASINCS RCINCS \
LIBS LIBPATH \
DIRS BLDDIRS CLEAN
## PROPS_ACCUMULATE_L_LNK
......@@ -1207,7 +1208,7 @@ PROPS_FETCHES_ACCUMULATE_L := SOURCES CLEAN
## KBUILD_COMPILE_CATEGTORIES
# Tools categories for compiling.
KBUILD_COMPILE_CATEGTORIES := AS C CXX OBJC OBJCXX RC
KBUILD_COMPILE_CATEGTORIES := AS C CXX PCH OBJC OBJCXX RC
## KBUILD_GENERIC_CATEGORIES
# Generic tool categories.
......
# $Id: GXX.kmk 3121 2017-10-31 10:58:59Z bird $
# $Id: GXX.kmk 3257 2019-01-03 02:46:05Z bird $
## @file
# kBuild Tool Config - Generic GCC using the system GCC, for building C++ code.
#
......@@ -36,6 +36,7 @@ TOOL_GXX := Generic GCC using the system GCC, for building C++ code.
# Tool Specific Properties
TOOL_GXX_CC ?= gcc$(HOSTSUFF_EXE)
TOOL_GXX_CXX ?= g++$(HOSTSUFF_EXE)
TOOL_GXX_PCH ?= $(TOOL_GXX_CXX)
TOOL_GXX_AS ?= gcc$(HOSTSUFF_EXE)
TOOL_GXX_AR ?= ar$(HOSTSUFF_EXE)
TOOL_GXX_RANLIB ?= ranlib$(HOSTSUFF_EXE)
......@@ -66,6 +67,14 @@ TOOL_GXX_CXXFLAGS.release ?= -O2
TOOL_GXX_CXXINCS ?=
TOOL_GXX_CXXDEFS ?=
TOOL_GXX_PCHOBJSUFF ?= .h.gch
TOOL_GXX_PCHFLAGS ?= $(TOOL_GXX_CXXFLAGS)
TOOL_GXX_PCHFLAGS.debug ?= $(TOOL_GXX_CXXFLAGS.debug)
TOOL_GXX_PCHFLAGS.profile ?= $(TOOL_GXX_CXXFLAGS.profile)
TOOL_GXX_PCHFLAGS.release ?= $(TOOL_GXX_CXXFLAGS.release)
TOOL_GXX_PCHINCS ?= $(TOOL_GXX_CXXINCS)
TOOL_GXX_PCHDEFS ?= $(TOOL_GXX_CXXDEFS)
TOOL_GXX_ASFLAGS ?= -x assembler-with-cpp
TOOL_GXX_ASFLAGS.debug ?= -g
TOOL_GXX_ASFLAGS.profile ?= -g
......@@ -119,14 +128,41 @@ endef
# @param $(outbase) Output basename (full). Use this for list files and such.
# @param $(objsuff) Object suffix.
TOOL_GXX_COMPILE_CXX_OUTPUT =
TOOL_GXX_COMPILE_CXX_DEPEND =
TOOL_GXX_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
TOOL_GXX_COMPILE_CXX_DEPORD =
define TOOL_GXX_COMPILE_CXX_CMDS
$(QUIET)$(TOOL_GXX_CXX) -c\
$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) \
$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
$(abspath $(source))
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
## Precompile C++ header.
# @param $(target) Normalized main target name.
# @param $(source) Source filename (relative).
# @param $(obj) Object file name. This shall be (re)created by the compilation.
# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
# @param $(flags) Flags.
# @param $(defs) Definitions. No -D or something.
# @param $(incs) Includes. No -I or something.
# @param $(dirdep) Directory creation dependency.
# @param $(deps) Other dependencies.
# @param $(outbase) Output basename (full). Use this for list files and such.
# @param $(objsuff) Object suffix.
TOOL_GXX_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
TOOL_GXX_COMPILE_PCH_DEPEND =
TOOL_GXX_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
define TOOL_GXX_COMPILE_PCH_CMDS
$(QUIET)$(TOOL_GXX_PCH) -c\
$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-o $(obj)\
$(abspath $(source))
$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
......@@ -170,8 +206,8 @@ TOOL_GXX_LINK_LIBRARY_OUTPUT =
TOOL_GXX_LINK_LIBRARY_DEPEND =
TOOL_GXX_LINK_LIBRARY_DEPORD =
define TOOL_GXX_LINK_LIBRARY_CMDS
$(QUIET)$(TOOL_GXX_AR) $(flags) $(out) $(objs)
$(call xargs,$(QUIET)$(TOOL_GXX_AR) $(flags) $(out),$(objs))
$(QUIET)$(TOOL_GXX_AR) $(flags) $(out) $(filter-out %.h.gch,$(objs))
$(call xargs,$(QUIET)$(TOOL_GXX_AR) $(flags) $(out),$(filter-out %.h.gch,$(objs)))
$(foreach lib,$(othersrc)\
,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
$(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
......@@ -203,7 +239,7 @@ TOOL_GXX_LINK_PROGRAM_OUTPUT =
TOOL_GXX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
TOOL_GXX_LINK_PROGRAM_DEPORD =
define TOOL_GXX_LINK_PROGRAM_CMDS
$(QUIET)$(TOOL_GXX_LD) $(flags) -o $(out) $(objs) \
$(QUIET)$(TOOL_GXX_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs)) \
$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
endef
......@@ -225,7 +261,7 @@ TOOL_GXX_LINK_DLL_OUTPUT =
TOOL_GXX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
TOOL_GXX_LINK_DLL_DEPORD =
define TOOL_GXX_LINK_DLL_CMDS
$(QUIET)$(TOOL_GXX_LD) $(TOOL_GXX_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
$(QUIET)$(TOOL_GXX_LD) $(TOOL_GXX_LDFLAGS.dll) $(flags) -o $(out) $(filter-out %.h.gch,$(objs)) \
$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
endef
# $Id: GXX3.kmk 3121 2017-10-31 10:58:59Z bird $
# $Id: GXX3.kmk 3257 2019-01-03 02:46:05Z bird $
## @file
# kBuild Tool Config - Generic GCC v3.2.x using the system GCC and Binutils, for building C++ code.
#
......@@ -36,6 +36,7 @@ TOOL_GXX3 := Generic GCC v3.2.x or later using the system GCC and Binutils, for
# Tool Specific Properties
TOOL_GXX3_CC ?= gcc$(HOSTSUFF_EXE)
TOOL_GXX3_CXX ?= g++$(HOSTSUFF_EXE)
TOOL_GXX3_PCH ?= $(TOOL_GXX3_CXX)
TOOL_GXX3_AS ?= gcc$(HOSTSUFF_EXE)
ifeq ($(KBUILD_TARGET),solaris)
TOOL_GXX3_AR ?= gar$(HOSTSUFF_EXE)
......@@ -72,6 +73,7 @@ endif
ifdef SLKRUNS
TOOL_GXX3_CC += -fmessage-length=0
TOOL_GXX3_CXX += -fmessage-length=0
TOOL_GXX3_PCH += -fmessage-length=0
endif
# General Properties used by kBuild
......@@ -83,7 +85,6 @@ TOOL_GXX3_CFLAGS.release ?= -O2
TOOL_GXX3_CINCS ?=
TOOL_GXX3_CDEFS ?=
TOOL_GXX3_CXXOBJSUFF ?= .o
TOOL_GXX3_CXXOBJSUFF ?= .o
TOOL_GXX3_CXXFLAGS ?=
TOOL_GXX3_CXXFLAGS.debug ?= -g
......@@ -92,6 +93,14 @@ TOOL_GXX3_CXXFLAGS.release ?= -O2
TOOL_GXX3_CXXINCS ?=
TOOL_GXX3_CXXDEFS ?=
TOOL_GXX3_PCHOBJSUFF ?= .h.gch
TOOL_GXX3_PCHFLAGS ?= $(TOOL_GXX3_CXXFLAGS)
TOOL_GXX3_PCHFLAGS.debug ?= $(TOOL_GXX3_CXXFLAGS.debug)
TOOL_GXX3_PCHFLAGS.profile ?= $(TOOL_GXX3_CXXFLAGS.profile)
TOOL_GXX3_PCHFLAGS.release ?= $(TOOL_GXX3_CXXFLAGS.release)
TOOL_GXX3_PCHINCS ?= $(TOOL_GXX3_CXXINCS)
TOOL_GXX3_PCHDEFS ?= $(TOOL_GXX3_CXXDEFS)
TOOL_GXX3_ASFLAGS ?= -x assembler-with-cpp
TOOL_GXX3_ASFLAGS.debug ?= -g
TOOL_GXX3_ASFLAGS.profile ?= -g
......@@ -120,10 +129,10 @@ TOOL_GXX3_LDFLAGS.profile ?= -g
# @param $(objsuff) Object suffix.
TOOL_GXX3_COMPILE_C_DEPEND =
TOOL_GXX3_COMPILE_C_DEPORD =
ifdef KBUILD_USE_KOBJCACHE
TOOL_GXX3_COMPILE_C_USES_KOBJCACHE = 1
TOOL_GXX3_COMPILE_C_OUTPUT = $(outbase).i
TOOL_GXX3_COMPILE_C_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
TOOL_GXX3_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
define TOOL_GXX3_COMPILE_C_CMDS
if "$(use_objcache)" != ""
$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
--kObjCache-cpp $(outbase).i\
$(TOOL_GXX3_CC) -E -o -\
......@@ -135,19 +144,15 @@ define TOOL_GXX3_COMPILE_C_CMDS
$(flags) -fpreprocessed -x c\
-o $(obj)\
-
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
else # !KBUILD_USE_KOBJCACHE
TOOL_GXX3_COMPILE_C_OUTPUT =
define TOOL_GXX3_COMPILE_C_CMDS
else
$(QUIET)$(TOOL_GXX3_CC) -c\
$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-o $(obj)\
$(abspath $(source))
endif
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
endif # !KBUILD_USE_KOBJCACHE
## Compile C++ source.
......@@ -162,36 +167,60 @@ endif # !KBUILD_USE_KOBJCACHE
# @param $(deps) Other dependencies.
# @param $(outbase) Output basename (full). Use this for list files and such.
# @param $(objsuff) Object suffix.
TOOL_GXX3_COMPILE_CXX_DEPEND =
TOOL_GXX3_COMPILE_CXX_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
TOOL_GXX3_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
TOOL_GXX3_COMPILE_CXX_DEPORD =
ifdef KBUILD_USE_KOBJCACHE
TOOL_GXX3_COMPILE_CXX_USES_KOBJCACHE = 1
TOOL_GXX3_COMPILE_CXX_OUTPUT = $(outbase).ii
TOOL_GXX3_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
define TOOL_GXX3_COMPILE_CXX_CMDS
if "$(use_objcache)" != ""
$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
--kObjCache-cpp $(outbase).ii\
$(TOOL_GXX3_CXX) -E -o -\
$(TOOL_GXX3_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
$(abspath $(source))\
--kObjCache-cc $(obj)\
$(TOOL_GXX3_CXX) -c\
$(flags) -fpreprocessed -x c++\
$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
-o $(obj)\
-
else
$(QUIET)$(TOOL_GXX3_CXX) -c\
$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
$(abspath $(source))
endif
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
else # !KBUILD_USE_KOBJCACHE
TOOL_GXX3_COMPILE_CXX_OUTPUT =
define TOOL_GXX3_COMPILE_CXX_CMDS
$(QUIET)$(TOOL_GXX3_CXX) -c\
$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
## Precompile C++ header.
# @param $(target) Normalized main target name.
# @param $(source) Source filename (relative).
# @param $(obj) Object file name. This shall be (re)created by the compilation.
# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
# @param $(flags) Flags.
# @param $(defs) Definitions. No -D or something.
# @param $(incs) Includes. No -I or something.
# @param $(dirdep) Directory creation dependency.
# @param $(deps) Other dependencies.
# @param $(outbase) Output basename (full). Use this for list files and such.
# @param $(objsuff) Object suffix.
TOOL_GXX3_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
TOOL_GXX3_COMPILE_PCH_DEPEND =
TOOL_GXX3_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
define TOOL_GXX3_COMPILE_PCH_CMDS
$(QUIET)$(TOOL_GXX3_PCH) -c\
$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-o $(obj)\
$(abspath $(source))
$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
endif # !KBUILD_USE_KOBJCACHE
## Compile Assembly source.
......@@ -236,7 +265,7 @@ TOOL_GXX3_LINK_LIBRARY_DEPORD =
define TOOL_GXX3_LINK_LIBRARY_CMDS
$(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
$(QUIET)$(APPEND) -n $(out).ar-script \
$(foreach o,$(objs), 'ADDMOD $(o)') \
$(foreach o,$(filter-out %.h.gch,$(objs)), 'ADDMOD $(o)') \
$(foreach o,$(filter-out %.def %.imp %.dll,$(othersrc)), 'ADDLIB $(o)')
$(if $(filter %.def %.imp %.dll,$(othersrc))\
,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
......@@ -268,7 +297,7 @@ TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$
$(filter %.def, $(othersrc))
TOOL_GXX3_LINK_PROGRAM_DEPORD =
define TOOL_GXX3_LINK_PROGRAM_CMDS
$(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(objs)\
$(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
$(filter %.def, $(othersrc))\
$(foreach p,$(libpath), -L$(p))\
$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
......@@ -304,7 +333,7 @@ TOOL_GXX3_LINK_DLL_DEPORD =
define TOOL_GXX3_LINK_DLL_CMDS
$(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\
$(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\
$(objs)\
$(filter-out %.h.gch,$(objs))\
$(filter %.def, $(othersrc))\
$(foreach p,$(libpath), -L$(p))\
$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
......@@ -338,7 +367,7 @@ TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(
$(filter %.def, $(othersrc))
TOOL_GXX3_LINK_SYSMOD_DEPORD =
define TOOL_GXX3_LINK_SYSMOD_CMDS
$(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
$(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
$(filter %.def, $(othersrc))\
$(foreach p,$(libpath), -L$(p))\
$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
......
# $Id: GXX32.kmk 3121 2017-10-31 10:58:59Z bird $
# $Id: GXX32.kmk 3258 2019-01-03 05:34:09Z bird $
## @file
# kBuild Tool Config - Generic 32-bit GCC v3.2.x or later using the system GCC, for building C++ code.
#
......@@ -37,6 +37,7 @@ TOOL_GXX32 := Generic 32-bit GCC v3.2.x or later using the system GCC, for build
# Tool Specific Properties
TOOL_GXX32_CC ?= gcc$(HOSTSUFF_EXE) -m32
TOOL_GXX32_CXX ?= g++$(HOSTSUFF_EXE) -m32
TOOL_GXX32_PCH ?= $(TOOL_GXX32_CXX)
TOOL_GXX32_AS ?= gcc$(HOSTSUFF_EXE) -m32
TOOL_GXX32_AR ?= ar$(HOSTSUFF_EXE)
TOOL_GXX32_LD ?= g++$(HOSTSUFF_EXE) -m32
......@@ -78,7 +79,6 @@ TOOL_GXX32_CFLAGS.release ?= -O2
TOOL_GXX32_CINCS ?=
TOOL_GXX32_CDEFS ?=
TOOL_GXX32_CXXOBJSUFF ?= .o
TOOL_GXX32_CXXOBJSUFF ?= .o
TOOL_GXX32_CXXFLAGS ?=
TOOL_GXX32_CXXFLAGS.debug ?= -g
......@@ -87,6 +87,14 @@ TOOL_GXX32_CXXFLAGS.release ?= -O2
TOOL_GXX32_CXXINCS ?=
TOOL_GXX32_CXXDEFS ?=
TOOL_GXX32_PCHOBJSUFF ?= .h.gch
TOOL_GXX32_PCHFLAGS ?= $(TOOL_GXX32_CXXFLAGS)
TOOL_GXX32_PCHFLAGS.debug ?= $(TOOL_GXX32_CXXFLAGS.debug)
TOOL_GXX32_PCHFLAGS.profile ?= $(TOOL_GXX32_CXXFLAGS.profile)
TOOL_GXX32_PCHFLAGS.release ?= $(TOOL_GXX32_CXXFLAGS.release)
TOOL_GXX32_PCHINCS ?= $(TOOL_GXX32_CXXINCS)
TOOL_GXX32_PCHDEFS ?= $(TOOL_GXX32_CXXDEFS)
TOOL_GXX32_ASFLAGS ?= -x assembler-with-cpp
TOOL_GXX32_ASFLAGS.debug ?= -g
TOOL_GXX32_ASFLAGS.profile ?= -g
......@@ -115,10 +123,10 @@ TOOL_GXX32_LDFLAGS.profile ?= -g
# @param $(objsuff) Object suffix.
TOOL_GXX32_COMPILE_C_DEPEND =
TOOL_GXX32_COMPILE_C_DEPORD =
ifdef KBUILD_USE_KOBJCACHE
TOOL_GXX32_COMPILE_C_USES_KOBJCACHE = 1
TOOL_GXX32_COMPILE_C_OUTPUT = $(outbase).i
TOOL_GXX32_COMPILE_C_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
TOOL_GXX32_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
define TOOL_GXX32_COMPILE_C_CMDS
if "$(use_objcache)" != ""
$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
--kObjCache-cpp $(outbase).i\
$(TOOL_GXX32_CC) -E -o -\
......@@ -130,19 +138,15 @@ define TOOL_GXX32_COMPILE_C_CMDS
$(flags) -fpreprocessed -x c\
-o $(obj)\
-
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
else # !KBUILD_USE_KOBJCACHE
TOOL_GXX32_COMPILE_C_OUTPUT =
define TOOL_GXX32_COMPILE_C_CMDS
else
$(QUIET)$(TOOL_GXX32_CC) -c\
$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-o $(obj)\
$(abspath $(source))
endif
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
endif # !KBUILD_USE_KOBJCACHE
## Compile C++ source.
......@@ -157,36 +161,60 @@ endif # !KBUILD_USE_KOBJCACHE
# @param $(deps) Other dependencies.
# @param $(outbase) Output basename (full). Use this for list files and such.
# @param $(objsuff) Object suffix.
TOOL_GXX32_COMPILE_CXX_DEPEND =
TOOL_GXX32_COMPILE_CXX_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
TOOL_GXX32_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
TOOL_GXX32_COMPILE_CXX_DEPORD =
ifdef KBUILD_USE_KOBJCACHE
TOOL_GXX32_COMPILE_CXX_USES_KOBJCACHE = 1
TOOL_GXX32_COMPILE_CXX_OUTPUT = $(outbase).ii
TOOL_GXX32_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
define TOOL_GXX32_COMPILE_CXX_CMDS
if "$(use_objcache)" != ""
$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
--kObjCache-cpp $(outbase).ii\
$(TOOL_GXX32_CXX) -E -o -\
$(TOOL_GXX32_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
$(abspath $(source))\
--kObjCache-cc $(obj)\
$(TOOL_GXX32_CXX) -c\
$(flags) -fpreprocessed -x c++\
$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
-o $(obj)\
-
else
$(QUIET)$(TOOL_GXX32_CXX) -c\
$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
$(abspath $(source))
endif
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
else # !KBUILD_USE_KOBJCACHE
TOOL_GXX32_COMPILE_CXX_OUTPUT =
define TOOL_GXX32_COMPILE_CXX_CMDS
$(QUIET)$(TOOL_GXX32_CXX) -c\
$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
## Precompile C++ header.
# @param $(target) Normalized main target name.
# @param $(source) Source filename (relative).
# @param $(obj) Object file name. This shall be (re)created by the compilation.
# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
# @param $(flags) Flags.
# @param $(defs) Definitions. No -D or something.
# @param $(incs) Includes. No -I or something.
# @param $(dirdep) Directory creation dependency.
# @param $(deps) Other dependencies.
# @param $(outbase) Output basename (full). Use this for list files and such.
# @param $(objsuff) Object suffix.
TOOL_GXX32_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
TOOL_GXX32_COMPILE_PCH_DEPEND =
TOOL_GXX32_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
define TOOL_GXX32_COMPILE_PCH_CMDS
$(QUIET)$(TOOL_GXX32_PCH) -c\
$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-o $(obj)\
$(abspath $(source))
$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
endef
endif # !KBUILD_USE_KOBJCACHE
## Compile Assembly source.
......@@ -230,10 +258,10 @@ TOOL_GXX32_LINK_LIBRARY_DEPORD =
define TOOL_GXX32_LINK_LIBRARY_CMDS
$(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
$(QUIET)$(APPEND) -n $(out).ar-script \
$(foreach o,$(objs), 'ADDMOD $(o)') \
$(foreach o,$(filter-out %.h.gch,$(objs)), 'ADDMOD $(o)') \
$(foreach o,$(filter-out %.def %.imp %.dll,$(othersrc)), 'ADDLIB $(o)')
$(if $(filter %.def %.imp %.dll,$(othersrc))\
,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
,$(TOOL_GXX32_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
$(QUIET)$(APPEND) $(out).ar-script 'SAVE'
$(QUIET)$(APPEND) $(out).ar-script 'END'
......@@ -262,7 +290,7 @@ TOOL_GXX32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),
$(filter %.def, $(othersrc))
TOOL_GXX32_LINK_PROGRAM_DEPORD =
define TOOL_GXX32_LINK_PROGRAM_CMDS
$(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(objs)\
$(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
$(foreach p,$(libpath), -L$(p))\
$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
$(call TOOL_GXX32_LD_MAP,$(outbase).map)
......@@ -297,7 +325,7 @@ TOOL_GXX32_LINK_DLL_DEPORD =
define TOOL_GXX32_LINK_DLL_CMDS
$(QUIET)$(TOOL_GXX32_LD) $(TOOL_GXX32_LDFLAGS.dll) $(flags) -o $(out)\
$(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX32_LD_SONAME,$(target),$(out)))\
$(objs)\
$(filter-out %.h.gch,$(objs))\
$(foreach p,$(libpath), -L$(p))\
$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
$(call TOOL_GXX32_LD_MAP,$(outbase).map)
......@@ -330,7 +358,7 @@ TOOL_GXX32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$
$(filter %.def, $(othersrc))
TOOL_GXX32_LINK_SYSMOD_DEPORD =
define TOOL_GXX32_LINK_SYSMOD_CMDS
$(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\