[72] | 1 | # $Id: footer.kmk 682 2006-12-08 00:03:03Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
[640] | 6 | # Copyright (c) 2004-2006 knut st. osmundsen <bird-srcspam@anduin.net>
|
---|
[72] | 7 | #
|
---|
| 8 | #
|
---|
| 9 | # This file is part of kBuild.
|
---|
| 10 | #
|
---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
[106] | 13 | # the Free Software Foundation; either version source of the License, or
|
---|
[72] | 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with kBuild; if not, write to the Free Software
|
---|
[353] | 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
[72] | 24 | #
|
---|
| 25 | #
|
---|
| 26 |
|
---|
| 27 | ifndef __footer_kmk__
|
---|
| 28 | # start-of-file-content
|
---|
| 29 |
|
---|
| 30 | #
|
---|
[530] | 31 | # Make sure that the core variables we defined in recursive expansion mode
|
---|
| 32 | # up in header.kmk get expanded before we really start using them. The kBuild
|
---|
| 33 | # functions added to kmk to speed stuff up assumes that the variables are
|
---|
| 34 | # expanded here.
|
---|
| 35 | #
|
---|
| 36 | PATH_OBJ := $(PATH_OBJ)
|
---|
| 37 | PATH_TARGET := $(PATH_TARGET)
|
---|
| 38 | PATH_INS := $(PATH_INS)
|
---|
| 39 | PATH_BIN := $(PATH_BIN)
|
---|
| 40 | PATH_DLL := $(PATH_DLL)
|
---|
| 41 | PATH_SYS := $(PATH_SYS)
|
---|
| 42 | PATH_LIB := $(PATH_LIB)
|
---|
| 43 | PATH_DOC := $(PATH_DOC)
|
---|
| 44 |
|
---|
| 45 | #
|
---|
[72] | 46 | # Variables.
|
---|
[73] | 47 | # (Some of these need initialization before including definitions using them.)
|
---|
[72] | 48 | #
|
---|
| 49 |
|
---|
| 50 | # all targets.
|
---|
[353] | 51 | ALL_TARGETS += \
|
---|
[640] | 52 | $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 53 | $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
[481] | 54 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
| 55 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 56 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 57 | $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 58 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 59 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 60 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 61 | $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
[72] | 62 |
|
---|
[447] | 63 | # all $(BUILD_TARGET) targets.
|
---|
| 64 | _ALL_BUILD_TARGET_TARGETS += \
|
---|
[640] | 65 | $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 66 | $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
[482] | 67 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
[481] | 68 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
[482] | 69 | $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 70 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 71 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 72 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 73 | $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
[447] | 74 |
|
---|
| 75 | # all $(BUILD_TARGET) targets.
|
---|
| 76 | _ALL_BUILD_PLATFORM_TARGETS += \
|
---|
[481] | 77 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH))
|
---|
[447] | 78 |
|
---|
[640] | 79 | # all targets making use of srcname.
|
---|
| 80 | _ALL_SRCNAME_TARGETS += \
|
---|
| 81 | $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 82 | $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
| 83 |
|
---|
[75] | 84 | # dependency files.
|
---|
| 85 | _DEPFILES :=
|
---|
| 86 |
|
---|
[380] | 87 | # included dependency files.
|
---|
| 88 | _DEPFILES_INCLUDED :=
|
---|
| 89 |
|
---|
| 90 |
|
---|
[75] | 91 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
| 92 | # Compiling or linking definition outputting other things that $@ and any
|
---|
| 93 | # required dependency file must add those output files to this variable.
|
---|
| 94 | _OUT_FILES :=
|
---|
| 95 |
|
---|
[353] | 96 | # Files which only requires cleaning up.
|
---|
| 97 | _CLEAN_FILES :=
|
---|
| 98 |
|
---|
[72] | 99 | # all of a type
|
---|
[219] | 100 | _OBJS :=
|
---|
[640] | 101 | _FETCHES :=
|
---|
| 102 | _DOWNLOADS:=
|
---|
| 103 | _UNPACKS :=
|
---|
| 104 | _PATCHES :=
|
---|
[222] | 105 | _BLDPROGS :=
|
---|
[219] | 106 | _LIBS :=
|
---|
| 107 | _DLLS :=
|
---|
| 108 | _PROGRAMS :=
|
---|
| 109 | _SYSMODS :=
|
---|
[353] | 110 | _INSTALLS :=
|
---|
[380] | 111 | _INSTALLS_DIRS :=
|
---|
[353] | 112 | _OTHERS :=
|
---|
[417] | 113 | _PACKING :=
|
---|
[380] | 114 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET)
|
---|
[189] | 115 | _IMPORT_LIBS :=
|
---|
[72] | 116 |
|
---|
[220] | 117 | # misc
|
---|
| 118 | pass_prev :=
|
---|
| 119 |
|
---|
| 120 |
|
---|
[72] | 121 | #
|
---|
[73] | 122 | # Basic macros
|
---|
| 123 | #
|
---|
| 124 |
|
---|
| 125 | ## Figure out the tool for a source
|
---|
[481] | 126 | # @param target source file
|
---|
| 127 | # @param source normalized main target
|
---|
| 128 | # @param type tooltype
|
---|
[222] | 129 | # @param bld_trg build target.
|
---|
[481] | 130 | # @param bld_trg_arch build target architecture.
|
---|
[552] | 131 | # @remark Obsoleted by kBuild helpers in kmk. Only required for gmake compatbility.
|
---|
[79] | 132 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
[481] | 133 | $($(target)_$(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 134 | $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 135 | $($(target)_$(source)_$(type)TOOL) \
|
---|
[481] | 136 | $($(target)_$(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 137 | $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
[106] | 138 | $($(target)_$(source)_TOOL) \
|
---|
[530] | 139 | $($(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 140 | $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
| 141 | $($(source)_$(type)TOOL) \
|
---|
| 142 | $($(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 143 | $($(source)_TOOL.$(bld_trg)) \
|
---|
| 144 | $($(source)_TOOL) \
|
---|
[481] | 145 | $($(target)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 146 | $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 147 | $($(target)_$(type)TOOL) \
|
---|
[481] | 148 | $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 149 | $($(target)_TOOL.$(bld_trg)) \
|
---|
[106] | 150 | $($(target)_TOOL) \
|
---|
[481] | 151 | $($(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 152 | $($(type)TOOL.$(bld_trg)) \
|
---|
[106] | 153 | $($(type)TOOL) \
|
---|
[481] | 154 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 155 | $(TOOL.$(bld_trg)) \
|
---|
[106] | 156 | $(TOOL) ))
|
---|
[73] | 157 |
|
---|
[78] | 158 | ## Figure out the tool for a target.
|
---|
[481] | 159 | # @param target normalized target.
|
---|
| 160 | # @param source tooltype.
|
---|
[222] | 161 | # @param bld_trg build target.
|
---|
[481] | 162 | # @param bld_trg_arch build target architecture.
|
---|
[79] | 163 | _TARGET_TOOL = $(strip $(firstword \
|
---|
[481] | 164 | $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 165 | $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
[106] | 166 | $($(target)_$(source)TOOL) \
|
---|
[481] | 167 | $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 168 | $($(target)_TOOL.$(bld_trg)) \
|
---|
[106] | 169 | $($(target)_TOOL) \
|
---|
[481] | 170 | $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[238] | 171 | $($(source)TOOL.$(bld_trg)) \
|
---|
[106] | 172 | $($(source)TOOL) \
|
---|
[481] | 173 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 174 | $(TOOL.$(bld_trg)) \
|
---|
[106] | 175 | $(TOOL) \
|
---|
[79] | 176 | ))
|
---|
[183] | 177 |
|
---|
[148] | 178 | ## Removes the drive letter from a path (if it has one)
|
---|
| 179 | # @param $1 the path
|
---|
| 180 | no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
[78] | 181 |
|
---|
[148] | 182 | ## Removes the root slash from a path (if it has one)
|
---|
| 183 | # @param $1 the path
|
---|
| 184 | no-root-slash=$(patsubst /%,%,$(1))
|
---|
| 185 |
|
---|
[73] | 186 | ## Figure out where to put object files.
|
---|
[110] | 187 | # @param $1 source file
|
---|
| 188 | # @param $2 normalized main target
|
---|
[316] | 189 | # @remark There are two major hacks here:
|
---|
| 190 | # 1. Source files in the output directory are translated into a gen/ subdir.
|
---|
[472] | 191 | # 2. Catch anyone specifying $(PATH_SUB_CURRENT)/sourcefile.c.
|
---|
[552] | 192 | # @remark obsoleted by kBuild helpers in kmk. Only required for gmake compatbility.
|
---|
[316] | 193 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename \
|
---|
[472] | 194 | $(patsubst $(PATH_ROOT)/%,%,$(patsubst $(PATH_SUB_CURRENT)/%,%,$(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))))
|
---|
[73] | 195 |
|
---|
| 196 | ## Figure out where to put object files.
|
---|
[110] | 197 | # @param $1 real target name.
|
---|
| 198 | # @param $2 normalized main target
|
---|
[148] | 199 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
|
---|
[73] | 200 |
|
---|
| 201 |
|
---|
[353] | 202 | ## Figure out the actual name of an installed file.
|
---|
| 203 | # @param $1 The file to install.
|
---|
| 204 | # @param $2 The target name.
|
---|
| 205 | # @param $3 The _INST value (can be empty).
|
---|
| 206 | # @param $4 The default directory to use when $3 is empty.
|
---|
| 207 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
---|
| 208 |
|
---|
| 209 |
|
---|
[73] | 210 | #
|
---|
[185] | 211 | # Check syntax which leads to weird syntax errors.
|
---|
| 212 | #
|
---|
| 213 |
|
---|
| 214 | ## Check
|
---|
| 215 | # @param $(target) Target name.
|
---|
| 216 | define def_check_target
|
---|
| 217 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
| 218 | $$(error $(target) have an incorrect template name. Remove any tabs!)
|
---|
| 219 | endif
|
---|
| 220 | endef
|
---|
| 221 | $(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
|
---|
| 222 |
|
---|
| 223 |
|
---|
| 224 | #
|
---|
[72] | 225 | # Include templates
|
---|
| 226 | #
|
---|
| 227 | _TEMPLATES := $(TEMPLATE)
|
---|
| 228 | define def_templates
|
---|
| 229 | ifdef $(target)_TEMPLATE
|
---|
| 230 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
| 231 | endif
|
---|
| 232 | endef
|
---|
| 233 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
| 234 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
| 235 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
| 236 |
|
---|
| 237 | define def_templates_include
|
---|
| 238 | ifndef TEMPLATE_$(template)
|
---|
[353] | 239 | include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
|
---|
[72] | 240 | endif
|
---|
| 241 | endef
|
---|
| 242 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
| 243 |
|
---|
[74] | 244 |
|
---|
[72] | 245 | #
|
---|
[412] | 246 | # Template Inheritance.
|
---|
| 247 | #
|
---|
| 248 | define def_template_extends_prop
|
---|
| 249 | ifndef TEMPLATE_$(template)_$(prop)
|
---|
[552] | 250 | ifdef TEMPLATE_$(parent)_$(prop)
|
---|
[412] | 251 | TEMPLATE_$(template)_$(prop) = $$(TEMPLATE_$(parent)_$(prop))
|
---|
[552] | 252 | endif
|
---|
[412] | 253 | endif
|
---|
| 254 | endef
|
---|
| 255 |
|
---|
[552] | 256 |
|
---|
[412] | 257 | define def_template_extends
|
---|
| 258 | ifdef TEMPLATE_$(template)_EXTENDS
|
---|
[552] | 259 | ifndef TEMPLATE_$(template)_EXTENDS_STATUS_
|
---|
| 260 | TEMPLATE_$(template)_EXTENDS_STATUS_ := 0
|
---|
| 261 | parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
|
---|
[412] | 262 |
|
---|
[552] | 263 | # recursivly process the parent if it's inherting from somebody too.
|
---|
| 264 | ifdef TEMPLATE_$(parent)_EXTENDS
|
---|
[594] | 265 | ifneq ($(TEMPLATE_$(parent)_EXTENDS_STATUS_),42)
|
---|
[552] | 266 | # foreach will create 'template' in a new variable context hiding our current variable.
|
---|
[594] | 267 | $(foreach template, $(parent), $(eval $(value def_template_extends)))
|
---|
[552] | 268 | parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
|
---|
| 269 | endif
|
---|
| 270 | endif
|
---|
| 271 |
|
---|
| 272 | # inherit properties.
|
---|
[660] | 273 | $(foreach prop, $(PROPS_SINGLE) $(PROPS_ACCUMULATE_R) $(PROPS_ACCUMULATE_L) $(PROPS_DEFERRED)\
|
---|
| 274 | $(addsuffix .$(BUILD_TARGET), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
| 275 | $(addsuffix .$(BUILD_TARGET).$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
| 276 | $(addsuffix .$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
| 277 | $(addsuffix .$(BUILD_TARGET_CPU), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
| 278 | $(addsuffix .$(BUILD_TYPE), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
[594] | 279 | ,$(eval $(def_template_extends_prop))) # exploits the 2 evaluation, so no value!
|
---|
[552] | 280 |
|
---|
| 281 | TEMPLATE_$(template)_EXTENDS_STATUS_ := 42
|
---|
| 282 | else
|
---|
| 283 | # protect against inheritance loops.
|
---|
| 284 | ifneq ($(TEMPLATE_$(template)_EXTENDS_STATUS_),42)
|
---|
| 285 | $(error kBuild: inheritance loop! template=$(template))
|
---|
| 286 | endif
|
---|
| 287 | endif
|
---|
[412] | 288 | endif
|
---|
| 289 | endef
|
---|
| 290 |
|
---|
| 291 | # $ (foreach template, $(_TEMPLATES), $(if TEMPLATE_$(template)_EXTENDS, $(eval $(value def_template_extends))))
|
---|
| 292 | $(foreach template, $(_TEMPLATES), $(eval $(value def_template_extends)))
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 | #
|
---|
[72] | 296 | # Common Inheritance
|
---|
| 297 | #
|
---|
| 298 |
|
---|
[353] | 299 | ## Inherit one template property in a non-accumulative manner.
|
---|
[72] | 300 | # @param $(prop) Property name
|
---|
| 301 | # @param $(target) Target name
|
---|
[78] | 302 | # @todo fix the precedence order for some properties.
|
---|
[72] | 303 | define def_inherit_template_one
|
---|
[78] | 304 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[72] | 305 | ifndef $(target)_$(prop)
|
---|
[353] | 306 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 307 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[72] | 308 | endif
|
---|
| 309 | endif
|
---|
[447] | 310 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 311 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
| 312 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 313 | $(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[79] | 314 | endif
|
---|
| 315 | endif
|
---|
[481] | 316 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 317 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 318 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 319 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 320 | endif
|
---|
| 321 | endif
|
---|
[455] | 322 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 323 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
| 324 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 325 | $(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 326 | endif
|
---|
| 327 | endif
|
---|
| 328 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 329 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
| 330 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 331 | $(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 332 | endif
|
---|
| 333 | endif
|
---|
[72] | 334 | endef
|
---|
| 335 |
|
---|
[353] | 336 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
| 337 | # @param 1: $(prop) Property name
|
---|
| 338 | # @param 2: $(target) Target name
|
---|
| 339 | # @todo fix the precedence order for some properties.
|
---|
| 340 | # @remark this define relies on double evaluation
|
---|
| 341 | define def_inherit_template_one_deferred
|
---|
| 342 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
| 343 | ifndef $(target)_$(prop)
|
---|
| 344 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 345 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 346 | endif
|
---|
| 347 | endif
|
---|
[447] | 348 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 349 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
| 350 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 351 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[353] | 352 | endif
|
---|
| 353 | endif
|
---|
[481] | 354 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 355 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 356 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 357 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 358 | endif
|
---|
| 359 | endif
|
---|
[455] | 360 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 361 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
| 362 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 363 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 364 | endif
|
---|
| 365 | endif
|
---|
| 366 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 367 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
| 368 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 369 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 370 | endif
|
---|
| 371 | endif
|
---|
[353] | 372 | endef
|
---|
| 373 |
|
---|
[660] | 374 | ## Inherit one acculumlative template property where the 'most significant' items are at the left end.
|
---|
[78] | 375 | # @param $(prop) Property name
|
---|
| 376 | # @param $(target) Target name
|
---|
[660] | 377 | define def_inherit_template_one_accumulate_l
|
---|
[78] | 378 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[353] | 379 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
[659] | 380 | $(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[442] | 381 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
[78] | 382 | endif
|
---|
[243] | 383 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
[353] | 384 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[659] | 385 | $(target)_$(prop).$(BUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[243] | 386 | endif
|
---|
[447] | 387 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
[659] | 388 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 389 | $(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[79] | 390 | endif
|
---|
[481] | 391 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 392 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
[659] | 393 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
[481] | 394 | endif
|
---|
[447] | 395 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 396 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
[659] | 397 | $(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
[79] | 398 | endif
|
---|
[447] | 399 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 400 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
[659] | 401 | $(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
[79] | 402 | endif
|
---|
[78] | 403 | endef
|
---|
| 404 |
|
---|
[660] | 405 | ## Inherit one acculumlative template property where the 'most significant' items are at the right end.
|
---|
| 406 | # First pass, $(value) referenced.
|
---|
| 407 | # @param $(prop) Property name
|
---|
| 408 | # @param $(target) Target name
|
---|
| 409 | define def_inherit_template_one_accumulate_r1
|
---|
| 410 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[661] | 411 | $(eval _$(target)_$(prop)_R = $(value $(target)_$(prop)))
|
---|
[660] | 412 | endif
|
---|
| 413 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
[661] | 414 | $(eval _$(target)_$(prop).$(BUILD_TYPE)_R = $(value $(target)_$(prop).$(BUILD_TYPE)))
|
---|
[660] | 415 | endif
|
---|
| 416 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
[661] | 417 | $(eval _$(target)_$(prop).$(bld_trg)_R = $(value $(target)_$(prop).$(bld_trg)))
|
---|
[660] | 418 | endif
|
---|
| 419 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
[661] | 420 | $(eval _$(target)_$(prop).$(bld_trg).$(bld_trg_arch)_R = $(value $(target)_$(prop).$(bld_trg).$(bld_trg_arch)))
|
---|
[660] | 421 | endif
|
---|
| 422 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
[661] | 423 | $(eval _$(target)_$(prop).$(bld_trg_cpu)_R = $(value $(target)_$(prop).$(bld_trg_cpu)))
|
---|
[660] | 424 | endif
|
---|
| 425 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
[661] | 426 | $(eval _$(target)_$(prop).$(bld_trg_arch)_R = $(value $(target)_$(prop).$(bld_trg_arch)))
|
---|
[660] | 427 | endif
|
---|
| 428 | endef
|
---|
| 429 |
|
---|
| 430 | ## Inherit one template property the other way around.
|
---|
| 431 | # Second pass, not $(value) referenced.
|
---|
| 432 | # @param $(prop) Property name
|
---|
| 433 | # @param $(target) Target name
|
---|
| 434 | define def_inherit_template_one_accumulate_r2
|
---|
| 435 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
| 436 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) $$(_$(target)_$(prop)_R)
|
---|
| 437 | endif
|
---|
| 438 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
| 439 | $(target)_$(prop).$(BUILD_TYPE) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)) $$(_$(target)_$(prop).$(BUILD_TYPE)_R)
|
---|
| 440 | endif
|
---|
| 441 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 442 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)) $$(_$(target)_$(prop).$(bld_trg)_R)
|
---|
| 443 | endif
|
---|
| 444 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 445 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)) $$(_$(target)_$(prop).$(bld_trg).$(bld_trg_arch)_R)
|
---|
| 446 | endif
|
---|
| 447 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 448 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)) $$(_$(target)_$(prop).$(bld_trg_cpu)_R)
|
---|
| 449 | endif
|
---|
| 450 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 451 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)) $$(_$(target)_$(prop).$(bld_trg_arch)_R)
|
---|
| 452 | endif
|
---|
| 453 | endef
|
---|
| 454 |
|
---|
| 455 |
|
---|
[72] | 456 | ## Inherit template properties for on target.
|
---|
| 457 | # @param $(target) Target name.
|
---|
| 458 | define def_inherit_template
|
---|
[447] | 459 | # Inherit any default template.
|
---|
| 460 | ifdef TEMPLATE
|
---|
| 461 | ifeq ($($(target)_TEMPLATE),)
|
---|
| 462 | $(eval $(target)_TEMPLATE:=$(TEMPLATE))
|
---|
| 463 | endif
|
---|
| 464 | endif
|
---|
| 465 | # Expand the template if specified.
|
---|
| 466 | ifneq ($($(target)_TEMPLATE),)
|
---|
[353] | 467 | $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
|
---|
| 468 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
---|
[660] | 469 | $(foreach prop,$(PROPS_ACCUMULATE_L),$(eval $(def_inherit_template_one_accumulate_l))) # += works fine (better) without value.
|
---|
| 470 | $(foreach prop,$(PROPS_ACCUMULATE_R),\
|
---|
| 471 | $(eval $(value def_inherit_template_one_accumulate_r1))\
|
---|
| 472 | $(eval $(def_inherit_template_one_accumulate_r2))\
|
---|
| 473 | ) # This is a hack! (but it appears to work)
|
---|
[447] | 474 | endif
|
---|
[72] | 475 | endef
|
---|
[353] | 476 |
|
---|
[72] | 477 | # Inherit template properties
|
---|
[447] | 478 | bld_trg := $(BUILD_TARGET)
|
---|
| 479 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 480 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
| 481 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(value def_inherit_template)))
|
---|
[72] | 482 |
|
---|
[447] | 483 | bld_trg := $(BUILD_PLATFORM)
|
---|
| 484 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
| 485 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
| 486 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(value def_inherit_template)))
|
---|
[72] | 487 |
|
---|
[447] | 488 |
|
---|
[72] | 489 | #
|
---|
[460] | 490 | # Include tools & sdks
|
---|
[183] | 491 | #
|
---|
[592] | 492 | _TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET_ARCH)) $(TOOL.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 493 | $(TOOL.$(BUILD_PLATFORM)) $(TOOL.$(BUILD_PLATFORM_ARCH)) $(TOOL.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
| 494 | $(TOOL)
|
---|
| 495 | _SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_TARGET_ARCH)) $(SDKS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 496 | $(SDKS.$(BUILD_PLATFORM)) $(SDKS.$(BUILD_PLATFORM_ARCH)) $(SDKS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
| 497 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 498 | $(SDKS)
|
---|
[460] | 499 | define def_tools_sdks_target_source
|
---|
[353] | 500 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
[460] | 501 | $($(source)_$(prop).$(_bld_trg)) \
|
---|
| 502 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
---|
[481] | 503 | $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 504 | $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 505 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
---|
| 506 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
---|
[353] | 507 | $($(source)_$(prop)) \
|
---|
| 508 | $($(target)_$(source)_$(prop))))
|
---|
[460] | 509 | $(eval _SDKS += \
|
---|
| 510 | $($(source)_SDKS.$(_bld_trg)) \
|
---|
| 511 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
---|
[481] | 512 | $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 513 | $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 514 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
---|
| 515 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
---|
[592] | 516 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 517 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
[460] | 518 | $($(source)_SDKS) \
|
---|
| 519 | $($(target)_$(source)_SDKS))
|
---|
[72] | 520 | endef
|
---|
[353] | 521 |
|
---|
[460] | 522 | define def_tools_sdks_target
|
---|
| 523 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
| 524 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
| 525 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
| 526 |
|
---|
[353] | 527 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
[460] | 528 | $($(target)_$(prop).$(_bld_trg)) \
|
---|
| 529 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
---|
[481] | 530 | $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[353] | 531 | $($(target)_$(prop))))
|
---|
[460] | 532 | $(eval _SDKS += \
|
---|
| 533 | $($(target)_SDKS.$(_bld_trg)) \
|
---|
| 534 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
---|
[481] | 535 | $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 536 | $($(target)_SDKS))
|
---|
[353] | 537 | $(foreach source, \
|
---|
[460] | 538 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
| 539 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
[481] | 540 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 541 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
[353] | 542 | $($(target)_SOURCES.$(BUILD_TYPE)) \
|
---|
| 543 | $($(target)_SOURCES) \
|
---|
[460] | 544 | , $(eval $(value def_tools_sdks_target_source)))
|
---|
[72] | 545 | endef
|
---|
[353] | 546 |
|
---|
[640] | 547 | define def_tools_srcname_target
|
---|
| 548 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
| 549 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
| 550 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
| 551 |
|
---|
| 552 | $(foreach source, $(notdir\
|
---|
| 553 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
| 554 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
| 555 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 556 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
| 557 | $($(target)_SOURCES.$(BUILD_TYPE)) \
|
---|
| 558 | $($(target)_SOURCES) \
|
---|
| 559 | ), $(eval $(value def_tools_sdks_target_source)))
|
---|
| 560 | endef
|
---|
| 561 |
|
---|
[460] | 562 | bld_trg := $(BUILD_TARGET)
|
---|
| 563 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 564 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
| 565 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
[640] | 566 | $(foreach target, $(_ALL_SRCNAME_TARGETS), $(eval $(value def_tools_srcname_target)))
|
---|
[72] | 567 |
|
---|
[460] | 568 | bld_trg := $(BUILD_PLATFORM)
|
---|
| 569 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
| 570 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
| 571 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
| 572 |
|
---|
| 573 |
|
---|
| 574 | # include TOOLS
|
---|
[72] | 575 | define def_tools_include
|
---|
| 576 | ifndef TOOL_$(tool)
|
---|
[353] | 577 | TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
|
---|
| 578 | ifeq ($(TOOL_$(tool)_KMK_FILE),)
|
---|
| 579 | $(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
|
---|
[72] | 580 | endif
|
---|
[353] | 581 | include $(TOOL_$(tool)_KMK_FILE)
|
---|
| 582 | endif
|
---|
[72] | 583 | endef
|
---|
[460] | 584 |
|
---|
| 585 | _TOOLS := $(sort $(_TOOLS))
|
---|
[353] | 586 | $(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
|
---|
[72] | 587 |
|
---|
| 588 |
|
---|
[460] | 589 | # include SDKS
|
---|
[122] | 590 | define def_sdks_include_one
|
---|
[72] | 591 | ifndef SDK_$(sdk)
|
---|
[353] | 592 | SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
|
---|
| 593 | ifeq ($(SDK_$(sdk)_KMK_FILE),)
|
---|
| 594 | $(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
|
---|
[72] | 595 | endif
|
---|
[353] | 596 | include $(SDK_$(sdk)_KMK_FILE)
|
---|
| 597 | endif
|
---|
[72] | 598 | endef
|
---|
[460] | 599 |
|
---|
| 600 | _SDKS := $(sort $(_SDKS))
|
---|
[353] | 601 | $(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
|
---|
[72] | 602 |
|
---|
[380] | 603 |
|
---|
[640] | 604 |
|
---|
[73] | 605 | #
|
---|
[640] | 606 | # Fetching Tools, Sources and Similar.
|
---|
| 607 | #
|
---|
| 608 | MD5SUM := md5sum
|
---|
| 609 |
|
---|
| 610 | ## generates the fetch rule
|
---|
| 611 | define def_fetch_src_fetch_rule
|
---|
| 612 | # Indirect goal for downloading something.
|
---|
[682] | 613 | .PRECIOUS: $(out)
|
---|
[640] | 614 | $(out) $($(target)_$(srcname)_FETCH_OUTPUT_): | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
| 615 | @$(ECHO) Downloading $(source)...
|
---|
| 616 | $$(RM) -f $(out) $(out).md5 ## @todo fancy stuff like download continuation
|
---|
| 617 | $($(target)_$(srcname)_FETCH_CMDS_)
|
---|
[682] | 618 | @$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
|
---|
| 619 | $(if $(md5),$$(MD5SUM) -c $(out).md5)
|
---|
[640] | 620 |
|
---|
| 621 |
|
---|
[682] | 622 |
|
---|
[640] | 623 | # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
|
---|
| 624 | $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
| 625 | @$(ECHO) Checking $(out) ($(source))...
|
---|
| 626 | $$(RM) -f $$@ $(out).md5
|
---|
| 627 | @# creates the .md5 we pass to md5sum.
|
---|
| 628 | @$(if $(md5),$(APPEND) $(out).md5 "$(md5) *$(out)")
|
---|
| 629 | @# if the file exists, perform md5sum, otherwise just fetch it.
|
---|
| 630 | $(if $(wildcard $(out)),\
|
---|
| 631 | $(MD5SUM) -c $(out).md5 || ( $(RM_EXT) -f $(out) && $(MAKE) -f $(MAKEFILE) $(out) ),\
|
---|
| 632 | $(MAKE) -f $(MAKEFILE) $(out) )
|
---|
| 633 | @$(APPEND) $$@
|
---|
| 634 |
|
---|
| 635 | _TARGET_$(target)_FETCHED += $(out).checked_$(md5)_$(size)
|
---|
| 636 |
|
---|
| 637 | endef
|
---|
| 638 |
|
---|
| 639 | ## generates the unpack rule
|
---|
| 640 | define def_fetch_src_unpack_rule
|
---|
| 641 | #$ (warning def_fetch_src_unpack_rule: source=$(source))
|
---|
| 642 |
|
---|
| 643 | # This is the unpack rule. it has an order-only dependency on the download check.
|
---|
| 644 | $(out) $($(target)_$(srcname)_UNPACK_OUTPUT_): $($(target)_$(srcname)_UNPACK_DEPEND_) \
|
---|
| 645 | | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size)
|
---|
| 646 | @$(ECHO) Unpacking $(source) into $(inst)...
|
---|
| 647 | $$(RM) -f $(out)
|
---|
| 648 | $($(target)_$(srcname)_UNPACK_CMDS_)
|
---|
| 649 | @$(APPEND) $(out) $(out)
|
---|
| 650 | @$(APPEND) $(out) $(out).check_$(md5)_$(size)
|
---|
| 651 |
|
---|
| 652 | $(eval _TARGET_$(target)_UNPACKED += $(out))
|
---|
| 653 | _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
|
---|
| 654 |
|
---|
| 655 | endef
|
---|
| 656 |
|
---|
| 657 | ## Processes a fetch source
|
---|
| 658 | #
|
---|
| 659 | define def_fetch_src
|
---|
| 660 | #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
|
---|
| 661 |
|
---|
| 662 | # common
|
---|
| 663 | srcname := $(notdir $(source))
|
---|
| 664 | inst := $(firstword \
|
---|
| 665 | $($(target)_$(source)_INST)\
|
---|
| 666 | $($(target)_$(srcname)_INST)\
|
---|
| 667 | $($(source)_INST)\
|
---|
| 668 | $($(srcname)_INST)\
|
---|
| 669 | $($(target)_INST)\
|
---|
| 670 | )
|
---|
| 671 | ifneq ($(patsubst %/,ok,$(inst)),ok)
|
---|
| 672 | $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
|
---|
| 673 | endif
|
---|
| 674 | INSTARGET_$(target)_$(srcname) := $(inst)
|
---|
| 675 | fetchdir := $(firstword \
|
---|
| 676 | $($(target)_$(source)_FETCHDIR)\
|
---|
| 677 | $($(target)_$(srcname)_FETCHDIR)\
|
---|
| 678 | $($(source)_FETCHDIR)\
|
---|
| 679 | $($(srcname)_FETCHDIR)\
|
---|
| 680 | $($(target)_FETCHDIR)\
|
---|
| 681 | $(FETCHDIR)\
|
---|
| 682 | $(PATH_TARGET)\
|
---|
| 683 | )
|
---|
| 684 | deps := \
|
---|
| 685 | $($(target)_$(source)_DEPS)\
|
---|
| 686 | $($(target)_$(srcname)_DEPS)\
|
---|
| 687 | $($(source)_DEPS)\
|
---|
| 688 | $($(srcname)_DEPS)\
|
---|
| 689 | $($(target)_DEPS)
|
---|
| 690 | md5 := $(firstword \
|
---|
| 691 | $($(target)_$(source)_MD5)\
|
---|
| 692 | $($(target)_$(srcname)_MD5)\
|
---|
| 693 | $($(source)_MD5)\
|
---|
| 694 | $($(srcname)_MD5)\
|
---|
| 695 | $($(target)_MD5)\
|
---|
| 696 | )
|
---|
| 697 | size := $(firstword \
|
---|
| 698 | $($(target)_$(source)_SIZE)\
|
---|
| 699 | $($(target)_$(srcname)_SIZE)\
|
---|
| 700 | $($(source)_SIZE)\
|
---|
| 701 | $($(srcname)_SIZE)\
|
---|
| 702 | $($(target)_SIZE)\
|
---|
| 703 | )
|
---|
| 704 | dep := # not legal for fetch and unpack tools
|
---|
| 705 |
|
---|
| 706 |
|
---|
| 707 | #
|
---|
| 708 | # The fetching.
|
---|
| 709 | #
|
---|
| 710 | out := $(fetchdir)/$(srcname)
|
---|
| 711 | archive := $(out)
|
---|
| 712 | TARGET_$(target)_$(srcname) := $(out)
|
---|
| 713 | dirdep := $(call DIRDEP,$(fetchdir))
|
---|
| 714 | tool := $(firstword \
|
---|
| 715 | $($(target)_$(source)_FETCHTOOL)\
|
---|
| 716 | $($(target)_$(srcname)_FETCHTOOL)\
|
---|
| 717 | $($(target)_$(source)_TOOL)\
|
---|
| 718 | $($(target)_$(srcname)_TOOL)\
|
---|
| 719 | $($(source)_FETCHTOOL)\
|
---|
| 720 | $($(srcname)_FETCHTOOL)\
|
---|
| 721 | $($(source)_TOOL)\
|
---|
| 722 | $($(srcname)_TOOL)\
|
---|
| 723 | $($(target)_FETCHTOOL)\
|
---|
| 724 | $($(target)_TOOL)\
|
---|
| 725 | )
|
---|
| 726 | flags :=\
|
---|
| 727 | $(TOOL_$(tool)_FETCHFLAGS)\
|
---|
| 728 | $(FETCHFLAGS)\
|
---|
| 729 | $($(target)_FETCHFLAGS)\
|
---|
| 730 | $($(srcname)_FETCHFLAGS)\
|
---|
| 731 | $($(source)_FETCHFLAGS)\
|
---|
| 732 | $($(target)_$(srcname)_FETCHFLAGS)\
|
---|
| 733 | $($(target)_$(source)_FETCHFLAGS)
|
---|
| 734 |
|
---|
| 735 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
|
---|
| 736 |
|
---|
| 737 | ifndef TOOL_$(tool)_FETCH_CMDS
|
---|
| 738 | $(warning kBuild: tools: \
|
---|
| 739 | 1 $($(target)_$(source)_FETCHTOOL)\
|
---|
| 740 | 2 $($(target)_$(srcname)_FETCHTOOL)\
|
---|
| 741 | 3 $($(target)_$(source)_TOOL)\
|
---|
| 742 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
| 743 | 5 $($(source)_FETCHTOOL)\
|
---|
| 744 | 6 $($(srcname)_FETCHTOOL)\
|
---|
| 745 | 7 $($(source)_TOOL)\
|
---|
| 746 | 8 $($(srcname)_TOOL)\
|
---|
| 747 | 9 $($(target)_FETCHTOOL)\
|
---|
| 748 | 10 $($(target)_TOOL) )
|
---|
| 749 | $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
|
---|
| 750 | endif
|
---|
| 751 |
|
---|
| 752 | # call the tool
|
---|
| 753 | $(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS)
|
---|
| 754 | $(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT)
|
---|
| 755 | $(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
|
---|
| 756 | $(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep)
|
---|
| 757 |
|
---|
| 758 | # generate the fetch rule.
|
---|
| 759 | $(eval $(def_fetch_src_fetch_rule))
|
---|
| 760 |
|
---|
| 761 |
|
---|
| 762 | #
|
---|
| 763 | # The unpacking / installing.
|
---|
| 764 | #
|
---|
| 765 | out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
|
---|
| 766 | dirdep := $(call DIRDEP,$(inst))
|
---|
| 767 | tool := $(firstword \
|
---|
| 768 | $($(target)_$(source)_UNPACKTOOL)\
|
---|
| 769 | $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
| 770 | $($(target)_$(source)_TOOL)\
|
---|
| 771 | $($(target)_$(srcname)_TOOL)\
|
---|
| 772 | $($(source)_UNPACKTOOL)\
|
---|
| 773 | $($(srcname)_UNPACKTOOL)\
|
---|
| 774 | $($(source)_TOOL)\
|
---|
| 775 | $($(srcname)_TOOL)\
|
---|
| 776 | $($(target)_UNPACKTOOL)\
|
---|
| 777 | $($(target)_TOOL) \
|
---|
| 778 | )
|
---|
| 779 | ifeq ($(tool),)
|
---|
| 780 | tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
|
---|
| 781 | $(eval $(value def_tools_include))
|
---|
| 782 | endif
|
---|
| 783 | flags :=\
|
---|
| 784 | $(TOOL_$(tool)_UNPACKFLAGS)\
|
---|
| 785 | $(UNPACKFLAGS)\
|
---|
| 786 | $($(target)_UNPACKFLAGS)\
|
---|
| 787 | $($(srcname)_UNPACKFLAGS)\
|
---|
| 788 | $($(source)_UNPACKFLAGS)\
|
---|
| 789 | $($(target)_$(srcname)_UNPACKFLAGS)\
|
---|
| 790 | $($(target)_$(source)_UNPACKFLAGS)
|
---|
| 791 |
|
---|
| 792 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
|
---|
| 793 | ifndef TOOL_$(tool)_UNPACK_CMDS
|
---|
| 794 | $(warning kBuild: tools: \
|
---|
| 795 | 1 $($(target)_$(source)_UNPACKTOOL)\
|
---|
| 796 | 2 $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
| 797 | 3 $($(target)_$(source)_TOOL)\
|
---|
| 798 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
| 799 | 5 $($(source)_UNPACKTOOL)\
|
---|
| 800 | 6 $($(srcname)_UNPACKTOOL)\
|
---|
| 801 | 7 $($(source)_TOOL)\
|
---|
| 802 | 8 $($(srcname)_TOOL)\
|
---|
| 803 | 9 $($(target)_UNPACKTOOL)\
|
---|
| 804 | 10 $($(target)_TOOL) \
|
---|
| 805 | 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
|
---|
| 806 | )
|
---|
| 807 | $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
|
---|
| 808 | endif
|
---|
| 809 |
|
---|
| 810 | # call the tool
|
---|
| 811 | $(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS)
|
---|
| 812 | $(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT)
|
---|
| 813 | $(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
|
---|
| 814 | $(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep)
|
---|
| 815 |
|
---|
| 816 | # generate the fetch rule.
|
---|
| 817 | $(eval $(def_fetch_src_unpack_rule))
|
---|
| 818 |
|
---|
| 819 | _DIRS += $(inst) $(fetchdir)
|
---|
| 820 |
|
---|
| 821 | endef
|
---|
| 822 |
|
---|
| 823 |
|
---|
| 824 | ##
|
---|
| 825 | # Define the target level rules for a fetch.
|
---|
| 826 | # @param target
|
---|
| 827 | # @param out
|
---|
| 828 | # @param inst
|
---|
| 829 | # @param _TARGET_$(target)_FETCHED...
|
---|
| 830 | # @param bld_trg
|
---|
| 831 | # @param bld_trg_arch
|
---|
| 832 | define def_fetch_rules
|
---|
| 833 |
|
---|
| 834 | $(out): $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
|
---|
| 835 | @$(ECHO) Successfully fetched $(target)
|
---|
| 836 | $(RM) -f $$@ $$@.tmp
|
---|
| 837 | @$(APPEND) $$@.tmp ""
|
---|
| 838 | $(if $(_TARGET_$(target)_UNPACKED),$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
|
---|
| 839 | $(MV) -f $$@.tmp $$@
|
---|
| 840 |
|
---|
| 841 | $(out)_unfetched:
|
---|
| 842 | @$(ECHO) Unfetching $(target)...
|
---|
| 843 | $(RM) -f $$(shell $$(CAT_EXT) $(out) 2> /dev/null)
|
---|
| 844 | # figure out how to make this quiet...
|
---|
| 845 | -$(RMDIR) -p $(dir $(out)) $$(sort $$(dir $$(shell $$(CAT_EXT) $(out) 2> /dev/null)))
|
---|
| 846 | $(RM) -f $(out)
|
---|
| 847 | -$(RMDIR) -p $(dir $(out))
|
---|
| 848 |
|
---|
| 849 | endef
|
---|
| 850 |
|
---|
| 851 |
|
---|
| 852 | ##
|
---|
| 853 | # Deal with one fetch target.
|
---|
| 854 | # @param target
|
---|
| 855 | # @param bld_trg
|
---|
| 856 | # @param bld_trg_arch
|
---|
| 857 | define def_fetch
|
---|
| 858 |
|
---|
| 859 | # common
|
---|
| 860 | INSTARGET_$(target) := $($(target)_INST)
|
---|
| 861 | ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
|
---|
[679] | 862 | $(error kBuild: Bad or missing INST property for target '$(target)'. \
|
---|
| 863 | $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
|
---|
[640] | 864 | endif
|
---|
| 865 | _TARGET_$(target)_FETCHED :=
|
---|
| 866 | _TARGET_$(target)_UNPACKED :=
|
---|
| 867 | _TARGET_$(target)_DIGEST :=
|
---|
| 868 |
|
---|
| 869 | # The 'sources'.
|
---|
| 870 | #$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)))
|
---|
| 871 | $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
| 872 | $(eval $(value def_fetch_src)))
|
---|
| 873 |
|
---|
| 874 | # The target.
|
---|
| 875 | inst := $(INSTARGET_$(target))
|
---|
| 876 | out := $(inst)_kBuild_fetch_$(target)
|
---|
| 877 |
|
---|
| 878 | $(eval $(def_fetch_rules))
|
---|
| 879 |
|
---|
| 880 | _FETCHES += $(out)
|
---|
| 881 | _DOWNLOADS += $(_TARGET_$(target)_FETCHED)
|
---|
| 882 | _UNPACKS += $(_TARGET_$(target)_UNPACKED)
|
---|
| 883 | _UNFETCHES += $(out)_unfetched
|
---|
| 884 | _DIRS += $(inst)
|
---|
| 885 |
|
---|
| 886 | endef
|
---|
| 887 |
|
---|
| 888 | # Walk the FETCH target lists.
|
---|
| 889 | bld_trg := $(BUILD_TARGET)
|
---|
| 890 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 891 | $(foreach target, $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 892 | $(eval $(value def_fetch)))
|
---|
| 893 |
|
---|
| 894 | # some aliases.
|
---|
| 895 | download: $(_DOWNLOADS)
|
---|
| 896 | unpack: $(_UNPACK)
|
---|
| 897 | fetches: $(_FETCHES)
|
---|
| 898 | unfetches: $(_UNFETCHES)
|
---|
| 899 |
|
---|
| 900 |
|
---|
| 901 |
|
---|
| 902 | ##
|
---|
| 903 | ## Patching.
|
---|
| 904 | ##
|
---|
| 905 | ##
|
---|
| 906 | #define def_fetch_src
|
---|
| 907 | #
|
---|
| 908 | #endef
|
---|
| 909 | #
|
---|
| 910 | #
|
---|
| 911 | ## Deal with one patch target.
|
---|
| 912 | #define def_patch
|
---|
| 913 | #
|
---|
| 914 | #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
| 915 | # $(eval $(value def_patch_one)))
|
---|
| 916 | #
|
---|
| 917 | #_PATCHES +=
|
---|
| 918 | #endef
|
---|
| 919 | #
|
---|
| 920 | #$(foreach target, $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 921 | # $(eval $(value def_patch)))
|
---|
| 922 | #
|
---|
| 923 |
|
---|
| 924 |
|
---|
| 925 | #
|
---|
[73] | 926 | # Object processing.
|
---|
| 927 | #
|
---|
[72] | 928 |
|
---|
[380] | 929 | ## wrapper the compile command dependency check.
|
---|
| 930 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
[552] | 931 | ifneq ($(filter comp-vars,$(KMK_FEATURES)),)
|
---|
[530] | 932 | _DEP_COMPILE_CMDS = $(comp-vars $(target)_$(source)_CMDS_PREV_,$(target)_$(source)_CMDS_,FORCE)
|
---|
| 933 | else
|
---|
[380] | 934 | _DEP_COMPILE_CMDS = $(if $(subst $(strip $($(target)_$(source)_CMDS_PREV_)),,$(strip $($(target)_$(source)_CMDS_))),FORCE,)
|
---|
[530] | 935 | endif
|
---|
[380] | 936 | else
|
---|
| 937 | _DEP_COMPILE_CMDS =
|
---|
| 938 | endif
|
---|
| 939 |
|
---|
| 940 | ## Generates the rules for building a specific object, and the '::' aliases
|
---|
| 941 | # for building a source file.
|
---|
[353] | 942 | # @param $(obj) The object file.
|
---|
[380] | 943 | define def_target_source_rule
|
---|
| 944 | $(obj) $($(target)_$(source)_OUTPUT_): \
|
---|
| 945 | $($(target)_$(source)_DEPEND_) \
|
---|
| 946 | $(_DEP_COMPILE_CMDS) \
|
---|
| 947 | | \
|
---|
| 948 | $($(target)_$(source)_DEPORD_)
|
---|
| 949 | $(call MSG_L1,Creating $$@)
|
---|
[472] | 950 | $(RM) -f $(dep) $(obj) $($(target)_$(source)_OUTPUT_)
|
---|
[380] | 951 | $(custom_pre)
|
---|
[412] | 952 |
|
---|
[380] | 953 | $($(target)_$(source)_CMDS_)
|
---|
| 954 |
|
---|
| 955 | $(custom_post)
|
---|
| 956 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
| 957 | @$(APPEND) "$(dep)"
|
---|
| 958 | @$(APPEND) "$(dep)" 'define $(target)_$(source)_CMDS_PREV_'
|
---|
| 959 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_$(source)_CMDS_))'
|
---|
| 960 | @$(APPEND) "$(dep)" 'endef'
|
---|
[412] | 961 | endif
|
---|
[380] | 962 |
|
---|
[353] | 963 | $(basename $(notdir $(obj))).o::
|
---|
[442] | 964 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
[445] | 965 | $(basename $(notdir $(obj))).obj::
|
---|
[442] | 966 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
[353] | 967 | endef
|
---|
[205] | 968 |
|
---|
[353] | 969 |
|
---|
[380] | 970 | ## wrapper the link command dependency check.
|
---|
| 971 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
[581] | 972 | ifneq ($(filter comp-vars,$(KMK_FEATURES)),)
|
---|
| 973 | _DEP_LINK_CMDS = $(comp-vars $(target)_CMDS_PREV_,$(target)_CMDS_,FORCE)
|
---|
| 974 | else
|
---|
[380] | 975 | _DEP_LINK_CMDS = $(if $(subst $(strip $($(target)_CMDS_PREV_)),,$(strip $($(target)_CMDS_))),FORCE,)
|
---|
[581] | 976 | endif
|
---|
[380] | 977 | else
|
---|
| 978 | _DEP_LINK_CMDS =
|
---|
| 979 | endif
|
---|
| 980 |
|
---|
| 981 | ## Generate the link rule for a target.
|
---|
| 982 | # @param $(target) The normalized target name.
|
---|
| 983 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
| 984 | # @param $(dep) The name of the dependency file.
|
---|
| 985 | # @param $(out)
|
---|
| 986 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
| 987 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
| 988 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
| 989 | # @param $($(target)_CMDS_) The link commands.
|
---|
| 990 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
| 991 | define def_link_rule
|
---|
| 992 | $(out) $($(target)_OUTPUT_): \
|
---|
| 993 | $($(target)_DEPEND_) \
|
---|
| 994 | $(_DEP_LINK_CMDS) \
|
---|
| 995 | | \
|
---|
| 996 | $($(target)_DEPORD_)
|
---|
| 997 | $(call MSG_L1,Creating $$@)
|
---|
[473] | 998 | $(RM) -f $(dep) $(out) $($(target)_OUTPUT_)
|
---|
[380] | 999 | $(custom_pre)
|
---|
[412] | 1000 |
|
---|
[380] | 1001 | $($(target)_CMDS_)
|
---|
| 1002 |
|
---|
| 1003 | $(custom_post)
|
---|
[524] | 1004 | ifndef NO_LINK_CMDS_DEPS
|
---|
[380] | 1005 | @$(APPEND) "$(dep)" 'define $(target)_CMDS_PREV_'
|
---|
| 1006 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_CMDS_))'
|
---|
| 1007 | @$(APPEND) "$(dep)" 'endef'
|
---|
[412] | 1008 | endif
|
---|
[380] | 1009 |
|
---|
| 1010 | $(basename $(notdir $(out)))::
|
---|
[442] | 1011 | + $$(MAKE) -f $$(MAKEFILE) $(out)
|
---|
[380] | 1012 | endef
|
---|
| 1013 |
|
---|
| 1014 |
|
---|
| 1015 | ## Generate the link & lib install rule
|
---|
| 1016 | # @param $(target) Normalized target name.
|
---|
| 1017 | # @param $(out) The build target.
|
---|
| 1018 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
| 1019 | # @param $(mode) The file mode (optional)
|
---|
| 1020 | define def_link_install_rule
|
---|
| 1021 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
| 1022 | $(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
| 1023 | endef
|
---|
| 1024 |
|
---|
| 1025 |
|
---|
| 1026 |
|
---|
[73] | 1027 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 1028 | # @param $(target) Normalized target name.
|
---|
| 1029 | # @param $(source) Source file name.
|
---|
| 1030 | # @param $(type) Source type. {C,CXX,AS}
|
---|
[221] | 1031 | # @param bld_type Build type.
|
---|
| 1032 | # @param bld_trg Build target.
|
---|
| 1033 | # @param bld_trg_arch Build target arch.
|
---|
| 1034 | # @param bld_trg_cpu Build target cpu.
|
---|
[592] | 1035 | # @remark obsoleted by kBuild helpers in kmk. Only required for limited gmake compatbility.
|
---|
[72] | 1036 | #
|
---|
[641] | 1037 | define def_target_source_c_cpp_asm_rc_old
|
---|
| 1038 | #$ (warning dbg: def_target_source_c_cpp_asm_rc_old: source='$(source)' target='$(target)' type='$(type)')
|
---|
[73] | 1039 |
|
---|
[353] | 1040 | tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
|
---|
| 1041 | outbase := $(call _OBJECT_BASE,$(source),$(target))
|
---|
| 1042 | PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 1043 | dirdep := $(call DIRDEP,$(dir $(outbase)))
|
---|
| 1044 | defs :=\
|
---|
[78] | 1045 | $(TOOL_$(tool)_DEFS)\
|
---|
[221] | 1046 | $(TOOL_$(tool)_DEFS.$(bld_type))\
|
---|
| 1047 | $(TOOL_$(tool)_DEFS.$(bld_trg))\
|
---|
| 1048 | $(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
|
---|
[481] | 1049 | $(TOOL_$(tool)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1050 | $(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
|
---|
[74] | 1051 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
[221] | 1052 | $(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
|
---|
[592] | 1053 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1054 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 1055 | $(SDKS.$(bld_trg)) \
|
---|
| 1056 | $(SDKS.$(bld_type)) \
|
---|
| 1057 | $(SDKS),\
|
---|
[353] | 1058 | $(SDK_$(sdk)_DEFS)\
|
---|
| 1059 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 1060 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 1061 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
[481] | 1062 | $(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1063 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 1064 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 1065 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 1066 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 1067 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[481] | 1068 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1069 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 1070 | $(DEFS)\
|
---|
[221] | 1071 | $(DEFS.$(bld_type))\
|
---|
| 1072 | $(DEFS.$(bld_trg))\
|
---|
| 1073 | $(DEFS.$(bld_trg_arch))\
|
---|
[481] | 1074 | $(DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1075 | $(DEFS.$(bld_trg_cpu))\
|
---|
[78] | 1076 | $($(type)DEFS)\
|
---|
[221] | 1077 | $($(type)DEFS.$(bld_type))\
|
---|
| 1078 | $($(type)DEFS.$(bld_trg))\
|
---|
| 1079 | $($(type)DEFS.$(bld_trg_arch))\
|
---|
[481] | 1080 | $($(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1081 | $($(type)DEFS.$(bld_trg_cpu))\
|
---|
[592] | 1082 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1083 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 1084 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1085 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 1086 | $($(target)_SDKS),\
|
---|
[353] | 1087 | $(SDK_$(sdk)_DEFS)\
|
---|
| 1088 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 1089 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 1090 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
[481] | 1091 | $(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1092 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 1093 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 1094 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 1095 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 1096 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[481] | 1097 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1098 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 1099 | $($(target)_DEFS)\
|
---|
[221] | 1100 | $($(target)_DEFS.$(bld_type))\
|
---|
| 1101 | $($(target)_DEFS.$(bld_trg))\
|
---|
| 1102 | $($(target)_DEFS.$(bld_trg_arch))\
|
---|
[481] | 1103 | $($(target)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1104 | $($(target)_DEFS.$(bld_trg_cpu))\
|
---|
[78] | 1105 | $($(target)_$(type)DEFS)\
|
---|
[221] | 1106 | $($(target)_$(type)DEFS.$(bld_type))\
|
---|
| 1107 | $($(target)_$(type)DEFS.$(bld_trg))\
|
---|
| 1108 | $($(target)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[481] | 1109 | $($(target)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1110 | $($(target)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
[592] | 1111 | $(foreach sdk, $($(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1112 | $($(source)_SDKS.$(bld_trg_arch)) \
|
---|
| 1113 | $($(source)_SDKS.$(bld_trg)) \
|
---|
| 1114 | $($(source)_SDKS.$(bld_type)) \
|
---|
| 1115 | $($(source)_SDKS),\
|
---|
[353] | 1116 | $(SDK_$(sdk)_DEFS)\
|
---|
| 1117 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 1118 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 1119 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
[481] | 1120 | $(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1121 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 1122 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 1123 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 1124 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 1125 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[481] | 1126 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1127 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 1128 | $($(source)_DEFS)\
|
---|
[221] | 1129 | $($(source)_DEFS.$(bld_type))\
|
---|
| 1130 | $($(source)_DEFS.$(bld_trg))\
|
---|
| 1131 | $($(source)_DEFS.$(bld_trg_arch))\
|
---|
[481] | 1132 | $($(source)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1133 | $($(source)_DEFS.$(bld_trg_cpu))\
|
---|
[73] | 1134 | $($(source)_$(type)DEFS)\
|
---|
[221] | 1135 | $($(source)_$(type)DEFS.$(bld_type))\
|
---|
| 1136 | $($(source)_$(type)DEFS.$(bld_trg))\
|
---|
| 1137 | $($(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[481] | 1138 | $($(source)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1139 | $($(source)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
[592] | 1140 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1141 | $($(target)_$(source)_SDKS.$(bld_trg_arch)) \
|
---|
| 1142 | $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
| 1143 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
| 1144 | $($(target)_$(source)_SDKS),\
|
---|
[353] | 1145 | $(SDK_$(sdk)_DEFS)\
|
---|
| 1146 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 1147 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 1148 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
[481] | 1149 | $(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1150 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 1151 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 1152 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 1153 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 1154 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[481] | 1155 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1156 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 1157 | $($(target)_$(source)_DEFS)\
|
---|
[221] | 1158 | $($(target)_$(source)_DEFS.$(bld_type))\
|
---|
| 1159 | $($(target)_$(source)_DEFS.$(bld_trg))\
|
---|
| 1160 | $($(target)_$(source)_DEFS.$(bld_trg_arch))\
|
---|
[481] | 1161 | $($(target)_$(source)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1162 | $($(target)_$(source)_DEFS.$(bld_trg_cpu))\
|
---|
[74] | 1163 | $($(target)_$(source)_$(type)DEFS)\
|
---|
[221] | 1164 | $($(target)_$(source)_$(type)DEFS.$(bld_type))\
|
---|
| 1165 | $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
|
---|
| 1166 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[481] | 1167 | $($(target)_$(source)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1168 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
|
---|
| 1169 | incs :=\
|
---|
[221] | 1170 | $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
[481] | 1171 | $($(target)_$(source)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1172 | $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 1173 | $($(target)_$(source)_$(type)INCS.$(bld_trg))\
|
---|
| 1174 | $($(target)_$(source)_$(type)INCS.$(bld_type))\
|
---|
[73] | 1175 | $($(target)_$(source)_$(type)INCS)\
|
---|
[221] | 1176 | $($(target)_$(source)_INCS.$(bld_trg_cpu))\
|
---|
[481] | 1177 | $($(target)_$(source)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1178 | $($(target)_$(source)_INCS.$(bld_trg_arch))\
|
---|
| 1179 | $($(target)_$(source)_INCS.$(bld_trg))\
|
---|
| 1180 | $($(target)_$(source)_INCS.$(bld_type))\
|
---|
[73] | 1181 | $($(target)_$(source)_INCS)\
|
---|
[592] | 1182 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1183 | $($(target)_$(source)_SDKS.$(bld_trg_arch)) \
|
---|
| 1184 | $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
| 1185 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
| 1186 | $($(target)_$(source)_SDKS),\
|
---|
[353] | 1187 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
[481] | 1188 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1189 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 1190 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 1191 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 1192 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 1193 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
[481] | 1194 | $(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1195 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 1196 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 1197 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 1198 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 1199 | $($(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
[481] | 1200 | $($(source)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1201 | $($(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 1202 | $($(source)_$(type)INCS.$(bld_trg))\
|
---|
| 1203 | $($(source)_$(type)INCS.$(bld_type))\
|
---|
[73] | 1204 | $($(source)_$(type)INCS)\
|
---|
[221] | 1205 | $($(source)_INCS.$(bld_trg_cpu))\
|
---|
[481] | 1206 | $($(source)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1207 | $($(source)_INCS.$(bld_trg_arch))\
|
---|
| 1208 | $($(source)_INCS.$(bld_trg))\
|
---|
| 1209 | $($(source)_INCS.$(bld_type))\
|
---|
[73] | 1210 | $($(source)_INCS)\
|
---|
[592] | 1211 | $(foreach sdk, $($(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1212 | $($(source)_SDKS.$(bld_trg_arch)) \
|
---|
| 1213 | $($(source)_SDKS.$(bld_trg)) \
|
---|
| 1214 | $($(source)_SDKS.$(bld_type)) \
|
---|
| 1215 | $($(source)_SDKS),\
|
---|
[353] | 1216 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
[481] | 1217 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1218 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 1219 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 1220 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 1221 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 1222 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
[481] | 1223 | $(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1224 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 1225 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 1226 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 1227 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 1228 | $($(target)_$(type)INCS.$(bld_trg_cpu))\
|
---|
[481] | 1229 | $($(target)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1230 | $($(target)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 1231 | $($(target)_$(type)INCS.$(bld_trg))\
|
---|
| 1232 | $($(target)_$(type)INCS.$(bld_type))\
|
---|
[73] | 1233 | $($(target)_$(type)INCS)\
|
---|
[221] | 1234 | $($(target)_INCS.$(bld_trg_cpu))\
|
---|
[481] | 1235 | $($(target)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1236 | $($(target)_INCS.$(bld_trg_arch))\
|
---|
| 1237 | $($(target)_INCS.$(bld_trg))\
|
---|
| 1238 | $($(target)_INCS.$(bld_type))\
|
---|
[73] | 1239 | $($(target)_INCS)\
|
---|
[592] | 1240 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1241 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 1242 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1243 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 1244 | $($(target)_SDKS),\
|
---|
[353] | 1245 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
[481] | 1246 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1247 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 1248 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 1249 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 1250 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 1251 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
[481] | 1252 | $(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1253 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 1254 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 1255 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 1256 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 1257 | $(INCS.$(bld_trg_cpu))\
|
---|
[481] | 1258 | $(INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1259 | $(INCS.$(bld_trg_arch))\
|
---|
| 1260 | $(INCS.$(bld_trg))\
|
---|
| 1261 | $(INCS.$(bld_type))\
|
---|
[73] | 1262 | $(INCS)\
|
---|
[592] | 1263 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1264 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 1265 | $(SDKS.$(bld_trg)) \
|
---|
| 1266 | $(SDKS.$(bld_type)) \
|
---|
| 1267 | $(SDKS),\
|
---|
[353] | 1268 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
[481] | 1269 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1270 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 1271 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 1272 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 1273 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 1274 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
[481] | 1275 | $(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1276 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 1277 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 1278 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 1279 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 1280 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
|
---|
[481] | 1281 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1282 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 1283 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
|
---|
| 1284 | $(TOOL_$(tool)_$(type)INCS.$(bld_type))\
|
---|
[353] | 1285 | $(TOOL_$(tool)_$(type)INCS)
|
---|
| 1286 | flags :=\
|
---|
[73] | 1287 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
[221] | 1288 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
|
---|
| 1289 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
|
---|
| 1290 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
[481] | 1291 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1292 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 1293 | $($(type)FLAGS)\
|
---|
[221] | 1294 | $($(type)FLAGS.$(bld_type))\
|
---|
| 1295 | $($(type)FLAGS.$(bld_trg))\
|
---|
| 1296 | $($(type)FLAGS.$(bld_trg_arch))\
|
---|
[481] | 1297 | $($(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1298 | $($(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 1299 | $($(target)_$(type)FLAGS)\
|
---|
[221] | 1300 | $($(target)_$(type)FLAGS.$(bld_type))\
|
---|
| 1301 | $($(target)_$(type)FLAGS.$(bld_trg))\
|
---|
| 1302 | $($(target)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
[481] | 1303 | $($(target)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1304 | $($(target)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 1305 | $($(source)_$(type)FLAGS)\
|
---|
[221] | 1306 | $($(source)_$(type)FLAGS.$(bld_type))\
|
---|
| 1307 | $($(source)_$(type)FLAGS.$(bld_trg))\
|
---|
| 1308 | $($(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
[481] | 1309 | $($(source)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1310 | $($(source)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 1311 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
[221] | 1312 | $($(target)_$(source)_$(type)FLAGS.$(bld_type))\
|
---|
| 1313 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
|
---|
| 1314 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
[481] | 1315 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1316 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
|
---|
[552] | 1317 | # this isn't 100% in sync with kBuild, but it doesn't matter as it's only for gmake now.
|
---|
[353] | 1318 | objsuff := $(firstword \
|
---|
[481] | 1319 | $($(target)_$(source)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1320 | $($(target)_$(source)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 1321 | $($(target)_$(source)_OBJSUFF)\
|
---|
[481] | 1322 | $($(source)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1323 | $($(source)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 1324 | $($(source)_OBJSUFF)\
|
---|
[481] | 1325 | $($(target)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1326 | $($(target)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 1327 | $($(target)_OBJSUFF)\
|
---|
[481] | 1328 | $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1329 | $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
|
---|
[74] | 1330 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
[353] | 1331 | $(SUFF_OBJ))
|
---|
| 1332 | obj := $(outbase)$(objsuff)
|
---|
| 1333 | deps := \
|
---|
[184] | 1334 | $($(target)_$(source)_DEPS)\
|
---|
[353] | 1335 | $($(target)_$(source)_DEPS.$(bld_type))\
|
---|
| 1336 | $($(target)_$(source)_DEPS.$(bld_trg))\
|
---|
| 1337 | $($(target)_$(source)_DEPS.$(bld_trg_arch))\
|
---|
[481] | 1338 | $($(target)_$(source)_DEPS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1339 | $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
|
---|
[184] | 1340 | $($(source)_DEPS)\
|
---|
[221] | 1341 | $($(source)_DEPS.$(bld_type))\
|
---|
| 1342 | $($(source)_DEPS.$(bld_trg))\
|
---|
[353] | 1343 | $($(source)_DEPS.$(bld_trg_arch))\
|
---|
[481] | 1344 | $($(source)_DEPS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1345 | $($(source)_DEPS.$(bld_trg_cpu))\
|
---|
[184] | 1346 | $($(target)_DEPS)\
|
---|
[353] | 1347 | $($(target)_DEPS.$(bld_type))\
|
---|
[481] | 1348 | $($(target)_DEPS.$(bld_trg))\
|
---|
[221] | 1349 | $($(target)_DEPS.$(bld_trg_arch))\
|
---|
[481] | 1350 | $($(target)_DEPS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1351 | $($(target)_DEPS.$(bld_trg_cpu))
|
---|
[73] | 1352 |
|
---|
[380] | 1353 | # dependencies
|
---|
| 1354 | dep := $(obj)$(SUFF_DEP)
|
---|
[524] | 1355 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
[380] | 1356 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 1357 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 1358 | endif
|
---|
[184] | 1359 |
|
---|
| 1360 | #$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
|
---|
[380] | 1361 | ifndef TOOL_$(tool)_COMPILE_$(type)_CMDS
|
---|
[353] | 1362 | $(warning kBuild: tools: \
|
---|
[481] | 1363 | 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1364 | 2 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
| 1365 | 3 $($(target)_$(source)_$(type)TOOL) \
|
---|
| 1366 | 4 $($(target)_$(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1367 | 5 $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
| 1368 | 6 $($(target)_$(source)_TOOL) \
|
---|
| 1369 | 7 $($(target)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1370 | 8 $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
| 1371 | 9 $($(target)_$(type)TOOL) \
|
---|
| 1372 | 10 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1373 | 11 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 1374 | 12 $($(target)_TOOL) \
|
---|
| 1375 | 13 $($(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1376 | 14 $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
| 1377 | 15 $($(source)_$(type)TOOL) \
|
---|
| 1378 | 16 $($(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1379 | 17 $($(source)_TOOL.$(bld_trg)) \
|
---|
| 1380 | 18 $($(source)_TOOL) \
|
---|
| 1381 | 19 $($(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1382 | 20 $($(type)TOOL.$(bld_trg)) \
|
---|
| 1383 | 21 $($(type)TOOL) \
|
---|
| 1384 | 22 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1385 | 23 $(TOOL.$(bld_trg)) \
|
---|
| 1386 | 24 $(TOOL) )
|
---|
[380] | 1387 | $(error kBuild: TOOL_$(tool)_COMPILE_$(type)_CMDS is not defined. source=$(source) target=$(target) )
|
---|
[97] | 1388 | endif
|
---|
[353] | 1389 |
|
---|
[380] | 1390 | # call the tool
|
---|
| 1391 | $(target)_$(source)_CMDS_ := $(TOOL_$(tool)_COMPILE_$(type)_CMDS)
|
---|
| 1392 | $(target)_$(source)_OUTPUT_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT)
|
---|
| 1393 | $(target)_$(source)_DEPEND_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPEND) $(deps) $(source)
|
---|
| 1394 | $(target)_$(source)_DEPORD_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPORD) $(dirdep)
|
---|
[73] | 1395 |
|
---|
[380] | 1396 | # generate the compile rule.
|
---|
| 1397 | $(eval $(def_target_source_rule))
|
---|
[205] | 1398 |
|
---|
[380] | 1399 | _OUT_FILES += $($(target)_$(source)_OUTPUT_)
|
---|
[353] | 1400 | $(target)_OBJS_ += $(obj)
|
---|
[73] | 1401 |
|
---|
| 1402 | endef
|
---|
| 1403 |
|
---|
[530] | 1404 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 1405 | # @param $(target) Normalized target name.
|
---|
| 1406 | # @param $(source) Source file name.
|
---|
| 1407 | # @param $(type) Source type. {C,CXX,AS}
|
---|
| 1408 | # @param bld_type Build type.
|
---|
| 1409 | # @param bld_trg Build target.
|
---|
| 1410 | # @param bld_trg_arch Build target arch.
|
---|
| 1411 | # @param bld_trg_cpu Build target cpu.
|
---|
| 1412 | #
|
---|
| 1413 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
[641] | 1414 | def_target_source_c_cpp_asm_rc_new = $(kb-src-one x)
|
---|
[530] | 1415 |
|
---|
[552] | 1416 | ifneq ($(filter kb-src-one,$(KMK_FEATURES)),)
|
---|
[641] | 1417 | def_target_source_c_cpp_asm_rc_var = def_target_source_c_cpp_asm_rc_new
|
---|
[530] | 1418 | else
|
---|
[641] | 1419 | def_target_source_c_cpp_asm_rc_var = def_target_source_c_cpp_asm_rc_old
|
---|
[530] | 1420 | endif
|
---|
| 1421 |
|
---|
[73] | 1422 | ## Generic macro for processing all target sources.
|
---|
[74] | 1423 | # @param $(target) Normalized target name.
|
---|
[73] | 1424 | define def_target_sources
|
---|
| 1425 | #$ (warning def_target_sources)
|
---|
| 1426 | # C sources
|
---|
[353] | 1427 | type := C
|
---|
[481] | 1428 | $(foreach source, $(filter %.c , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
[641] | 1429 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
[73] | 1430 |
|
---|
| 1431 | # C++ sources
|
---|
[353] | 1432 | type := CXX
|
---|
[481] | 1433 | $(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
[641] | 1434 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
[73] | 1435 |
|
---|
| 1436 | # ASM sources
|
---|
[353] | 1437 | type := AS
|
---|
[481] | 1438 | $(foreach source, $(filter %.asm %.s %.S , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
[641] | 1439 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
[353] | 1440 |
|
---|
[641] | 1441 | # Resource sources
|
---|
| 1442 | type := RC
|
---|
| 1443 | $(foreach source, $(filter %.rc , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
| 1444 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
| 1445 |
|
---|
[73] | 1446 | endef
|
---|
| 1447 |
|
---|
| 1448 |
|
---|
[219] | 1449 |
|
---|
[353] | 1450 | ## Generic macro for generating the install rule(s) for a target
|
---|
| 1451 | # and update the globals with default out.
|
---|
[219] | 1452 | #
|
---|
[353] | 1453 | # @param $(target) Normalized target name.
|
---|
| 1454 | # @param $(out) The output file.
|
---|
| 1455 | # @param $(definst) The default _INST value.
|
---|
| 1456 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
| 1457 | # @obsolete
|
---|
| 1458 | define def_target_install_pluss
|
---|
| 1459 | ifndef $(target)_NOINST
|
---|
| 1460 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 1461 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
[219] | 1462 |
|
---|
[353] | 1463 | $(eval $(def_link_install_rule))
|
---|
[239] | 1464 |
|
---|
[579] | 1465 | _INSTALLS += $(INSTARGET_$(target))
|
---|
[272] | 1466 |
|
---|
[353] | 1467 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
[579] | 1468 | $(typevar) += $(INSTARGET_$(target))
|
---|
[219] | 1469 | else
|
---|
[579] | 1470 | $(typevar) += $(out)
|
---|
[219] | 1471 | endif
|
---|
[353] | 1472 | else # _NOINST
|
---|
[579] | 1473 | $(typevar) += $(out)
|
---|
[353] | 1474 | endif
|
---|
| 1475 |
|
---|
[579] | 1476 | _OUT_FILES += $($(target)_OUTPUT_)
|
---|
[353] | 1477 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
| 1478 | _OBJS += $($(target)_OBJS_)
|
---|
| 1479 |
|
---|
[219] | 1480 | endef
|
---|
| 1481 |
|
---|
| 1482 |
|
---|
| 1483 |
|
---|
| 1484 | #
|
---|
[72] | 1485 | # LIBRARIES
|
---|
[73] | 1486 | #
|
---|
[72] | 1487 |
|
---|
| 1488 | ## Library (one).
|
---|
[74] | 1489 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 1490 | define def_lib
|
---|
[145] | 1491 | # library basics
|
---|
[222] | 1492 | ## @todo prefix
|
---|
[353] | 1493 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1494 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 1495 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 1496 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 1497 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
[78] | 1498 | ifeq ($(tool),)
|
---|
[353] | 1499 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
[78] | 1500 | endif
|
---|
[353] | 1501 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 1502 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 1503 | suff := $(firstword\
|
---|
[481] | 1504 | $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1505 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
[126] | 1506 | $($(target)_LIBSUFF)\
|
---|
[481] | 1507 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1508 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
[126] | 1509 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
[353] | 1510 | $(SUFF_LIB))
|
---|
| 1511 | out := $(outbase)$(suff)
|
---|
| 1512 | TARGET_$(target) := $(out)
|
---|
[643] | 1513 | $(target)_OBJS_ :=
|
---|
[145] | 1514 |
|
---|
| 1515 | # source -> object
|
---|
[353] | 1516 | $(eval $(value def_target_sources))
|
---|
[145] | 1517 |
|
---|
| 1518 | # library linking
|
---|
[353] | 1519 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
| 1520 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 1521 | flags :=\
|
---|
[74] | 1522 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
[221] | 1523 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
[74] | 1524 | $(ARFLAGS)\
|
---|
[221] | 1525 | $(ARFLAGS.$(bld_type))\
|
---|
[74] | 1526 | $($(target)_ARFLAGS)\
|
---|
[481] | 1527 | $($(target)_ARFLAGS.$(bld_type)) \
|
---|
| 1528 | $($(target)_ARFLAGS.$(bld_trg)) \
|
---|
| 1529 | $($(target)_ARFLAGS.$(bld_trg_arch)) \
|
---|
| 1530 | $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1531 | $($(target)_ARFLAGS.$(bld_trg_cpu))
|
---|
[353] | 1532 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
| 1533 | $($(target)_SOURCES) \
|
---|
| 1534 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1535 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
[481] | 1536 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
[353] | 1537 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1538 | $($(target)_SOURCES.$(bld_type)))
|
---|
[643] | 1539 | objs = $(filter %.o %.obj, \
|
---|
| 1540 | $($(target)_SOURCES) \
|
---|
| 1541 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1542 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 1543 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1544 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1545 | $($(target)_SOURCES.$(bld_type))) \
|
---|
| 1546 | $($(target)_OBJS_)
|
---|
[353] | 1547 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
[78] | 1548 | ## @todo fix dependencies on makefiles an such
|
---|
[353] | 1549 | deps := $($(target)_DEPS)
|
---|
[72] | 1550 |
|
---|
[380] | 1551 | # dependency file
|
---|
| 1552 | dep := $(out)$(SUFF_DEP)
|
---|
[524] | 1553 | ifndef NO_LINK_CMDS_DEPS
|
---|
[380] | 1554 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 1555 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 1556 | endif
|
---|
[72] | 1557 |
|
---|
[380] | 1558 | # check that the tool is defined.
|
---|
| 1559 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
| 1560 | $(warning kBuild: tools: \
|
---|
[481] | 1561 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1562 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 1563 | 3 $($(target)_$(source)TOOL) \
|
---|
| 1564 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1565 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 1566 | 6 $($(target)_TOOL) \
|
---|
| 1567 | 7 $($(source)TOOL) \
|
---|
| 1568 | 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1569 | 9 $($(source)TOOL.$(bld_trg)) \
|
---|
| 1570 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1571 | 11 $(TOOL.$(bld_trg)) \
|
---|
| 1572 | 12 $(TOOL) )
|
---|
[380] | 1573 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
| 1574 | endif
|
---|
| 1575 |
|
---|
| 1576 | # call the tool
|
---|
| 1577 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
| 1578 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
| 1579 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $(objs)
|
---|
| 1580 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep)
|
---|
| 1581 |
|
---|
[412] | 1582 | # generate the link rule.
|
---|
[380] | 1583 | $(eval $(def_link_rule))
|
---|
| 1584 |
|
---|
[353] | 1585 | # installing and globals
|
---|
| 1586 | definst := $(PATH_LIB)
|
---|
[380] | 1587 | typevar := _LIBS
|
---|
[353] | 1588 | $(eval $(value def_target_install_pluss))
|
---|
[72] | 1589 | endef
|
---|
| 1590 |
|
---|
| 1591 | # Process libraries
|
---|
[380] | 1592 | mode := 0644
|
---|
[481] | 1593 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
---|
[72] | 1594 |
|
---|
| 1595 |
|
---|
| 1596 | #
|
---|
[353] | 1597 | # Link operations.
|
---|
[72] | 1598 | #
|
---|
| 1599 |
|
---|
[353] | 1600 | ##
|
---|
| 1601 | # Link prolog
|
---|
| 1602 | #
|
---|
| 1603 | # @param $(target) Normalized target name.
|
---|
| 1604 | # @param $(EXT) EXE,DLL,SYS.
|
---|
| 1605 | # @param $(definst) The default _INST value.
|
---|
| 1606 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
[380] | 1607 | define def_link_common
|
---|
[353] | 1608 | # basics
|
---|
| 1609 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1610 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
| 1611 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
| 1612 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
[145] | 1613 |
|
---|
[353] | 1614 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
| 1615 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 1616 | suff := $(firstword \
|
---|
| 1617 | $($(target)_$(EXT)SUFF) \
|
---|
| 1618 | $($(target)_$(EXT)SUFF) \
|
---|
| 1619 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
| 1620 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
| 1621 | out := $(outbase)$(suff)
|
---|
| 1622 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 1623 | TARGET_$(target) := $(out)
|
---|
[643] | 1624 | $(target)_OBJS_ :=
|
---|
[353] | 1625 |
|
---|
[145] | 1626 | # source -> object
|
---|
[353] | 1627 | $(eval $(value def_target_sources))
|
---|
[145] | 1628 |
|
---|
[353] | 1629 | # more library stuff.
|
---|
| 1630 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
| 1631 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 1632 | flags :=\
|
---|
[74] | 1633 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
[221] | 1634 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
| 1635 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
| 1636 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 1637 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1638 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
[74] | 1639 | $(LDFLAGS)\
|
---|
[221] | 1640 | $(LDFLAGS.$(bld_type))\
|
---|
| 1641 | $(LDFLAGS.$(bld_trg))\
|
---|
| 1642 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 1643 | $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1644 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
[74] | 1645 | $($(target)_LDFLAGS)\
|
---|
[221] | 1646 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
| 1647 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
| 1648 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 1649 | $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1650 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
| 1651 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
| 1652 | $($(target)_SOURCES)\
|
---|
| 1653 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1654 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
[481] | 1655 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
[353] | 1656 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1657 | $($(target)_SOURCES.$(bld_type)))
|
---|
[643] | 1658 | objs = $(filter %.o %.obj, \
|
---|
| 1659 | $($(target)_SOURCES) \
|
---|
| 1660 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1661 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 1662 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1663 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1664 | $($(target)_SOURCES.$(bld_type))) \
|
---|
| 1665 | $($(target)_OBJS_)
|
---|
[353] | 1666 | libs :=\
|
---|
[221] | 1667 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1668 | $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1669 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
| 1670 | $($(target)_LIBS.$(bld_trg))\
|
---|
| 1671 | $($(target)_LIBS.$(bld_type))\
|
---|
[74] | 1672 | $($(target)_LIBS)\
|
---|
[592] | 1673 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1674 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 1675 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1676 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 1677 | $($(target)_SDKS),\
|
---|
[353] | 1678 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1679 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1680 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 1681 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 1682 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 1683 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 1684 | $(LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1685 | $(LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1686 | $(LIBS.$(bld_trg_arch))\
|
---|
| 1687 | $(LIBS.$(bld_trg))\
|
---|
| 1688 | $(LIBS.$(bld_type))\
|
---|
[74] | 1689 | $(LIBS)\
|
---|
[592] | 1690 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1691 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 1692 | $(SDKS.$(bld_trg)) \
|
---|
| 1693 | $(SDKS.$(bld_type)) \
|
---|
| 1694 | $(SDKS),\
|
---|
[353] | 1695 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1696 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1697 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 1698 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 1699 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 1700 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 1701 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1702 | $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1703 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
| 1704 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
| 1705 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
[353] | 1706 | $(TOOL_$(tool)_LIBS)
|
---|
| 1707 | libpath :=\
|
---|
[221] | 1708 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1709 | $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1710 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1711 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
| 1712 | $($(target)_LIBPATH.$(bld_type))\
|
---|
[74] | 1713 | $($(target)_LIBPATH)\
|
---|
[592] | 1714 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1715 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 1716 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1717 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 1718 | $($(target)_SDKS),\
|
---|
[353] | 1719 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1720 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1721 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1722 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 1723 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 1724 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 1725 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1726 | $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1727 | $(LIBPATH.$(bld_trg_arch))\
|
---|
| 1728 | $(LIBPATH.$(bld_trg))\
|
---|
| 1729 | $(LIBPATH.$(bld_type))\
|
---|
[74] | 1730 | $(LIBPATH)\
|
---|
[592] | 1731 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1732 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 1733 | $(SDKS.$(bld_trg)) \
|
---|
| 1734 | $(SDKS.$(bld_type)) \
|
---|
| 1735 | $(SDKS),\
|
---|
[353] | 1736 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1737 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1738 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1739 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 1740 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 1741 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 1742 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1743 | $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1744 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1745 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
| 1746 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
[353] | 1747 | $(TOOL_$(tool)_LIBPATH)
|
---|
| 1748 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
[74] | 1749 | ## @todo fix dependencies
|
---|
[353] | 1750 | deps := $($(target)_DEPS)
|
---|
| 1751 |
|
---|
| 1752 | ## @todo this stuff can't be working.
|
---|
| 1753 | custom_pre := $(strip $(firstword \
|
---|
[481] | 1754 | $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1755 | $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
| 1756 | $($(target)_CUSTOM_PRE.$(bld_trg))\
|
---|
| 1757 | $($(target)_CUSTOM_PRE.$(bld_type))\
|
---|
[74] | 1758 | $($(target)_CUSTOM_PRE)\
|
---|
[481] | 1759 | $(CUSTOM_PRE.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1760 | $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
| 1761 | $(CUSTOM_PRE.$(bld_trg))\
|
---|
| 1762 | $(CUSTOM_PRE.$(bld_type))\
|
---|
[74] | 1763 | $(CUSTOM_PRE)\
|
---|
[353] | 1764 | ))
|
---|
| 1765 | custom_post := $(strip $(firstword \
|
---|
[481] | 1766 | $($(target)_CUSTOM_POST.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1767 | $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
| 1768 | $($(target)_CUSTOM_POST.$(bld_trg))\
|
---|
| 1769 | $($(target)_CUSTOM_POST.$(bld_type))\
|
---|
[74] | 1770 | $($(target)_CUSTOM_POST)\
|
---|
[481] | 1771 | $(CUSTOM_POST.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1772 | $(CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
| 1773 | $(CUSTOM_POST.$(bld_trg))\
|
---|
| 1774 | $(CUSTOM_POST.$(bld_type))\
|
---|
[74] | 1775 | $(CUSTOM_POST)\
|
---|
[353] | 1776 | ))
|
---|
[72] | 1777 |
|
---|
[353] | 1778 | # installation targets
|
---|
| 1779 | ifndef $(target)_NOINST
|
---|
| 1780 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 1781 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
| 1782 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
| 1783 | $(typevar) += $(INSTARGET_$(target))
|
---|
| 1784 | else
|
---|
| 1785 | $(typevar) += $(out)
|
---|
| 1786 | endif
|
---|
| 1787 | # generate the install rule
|
---|
| 1788 | $(eval $(def_link_install_rule))
|
---|
| 1789 |
|
---|
| 1790 | else # NOINST
|
---|
| 1791 | INSTARGET_$(target) :=
|
---|
| 1792 | $(typevar) += $(out)
|
---|
| 1793 | endif # NOINST
|
---|
| 1794 |
|
---|
[380] | 1795 | # dependency file
|
---|
| 1796 | dep := $(outbase)$(SUFF_DEP)
|
---|
[524] | 1797 | ifndef NO_LINK_CMDS_DEPS
|
---|
[380] | 1798 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 1799 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 1800 | endif
|
---|
[353] | 1801 |
|
---|
[380] | 1802 | # check that the tool is defined.
|
---|
| 1803 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
| 1804 | $(warning kBuild: tools: \
|
---|
[481] | 1805 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1806 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 1807 | 3 $($(target)_$(source)TOOL) \
|
---|
| 1808 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1809 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 1810 | 6 $($(target)_TOOL) \
|
---|
| 1811 | 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1812 | 8 $($(source)TOOL.$(bld_trg)) \
|
---|
| 1813 | 9 $($(source)TOOL) \
|
---|
| 1814 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1815 | 11 $(TOOL.$(bld_trg)) \
|
---|
| 1816 | 12 $(TOOL) )
|
---|
[380] | 1817 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
| 1818 | endif
|
---|
[353] | 1819 |
|
---|
[380] | 1820 | # call the tool
|
---|
| 1821 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
| 1822 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
| 1823 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $(objs)
|
---|
| 1824 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep)
|
---|
[353] | 1825 |
|
---|
[412] | 1826 | # generate the link rule.
|
---|
[380] | 1827 | $(eval $(def_link_rule))
|
---|
| 1828 |
|
---|
[412] | 1829 |
|
---|
[380] | 1830 | # Update globals.
|
---|
[579] | 1831 | _OBJS += $($(target)_OBJS_)
|
---|
| 1832 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
[353] | 1833 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
[579] | 1834 | _INSTALLS += $(INSTARGET_$(target))
|
---|
[353] | 1835 |
|
---|
| 1836 | endef
|
---|
| 1837 |
|
---|
| 1838 |
|
---|
| 1839 | #
|
---|
| 1840 | # BLDPROGS
|
---|
| 1841 | #
|
---|
| 1842 |
|
---|
| 1843 | ## Build program (one).
|
---|
| 1844 | # @param $(target) Normalized target (program) name.
|
---|
| 1845 | define def_bldprog
|
---|
| 1846 |
|
---|
| 1847 | # set NOINST if not forced installation.
|
---|
| 1848 | ifndef $(target)_INST
|
---|
| 1849 | $(target)_NOINST := 1
|
---|
| 1850 | endif
|
---|
| 1851 |
|
---|
[380] | 1852 | # do the usual stuff.
|
---|
| 1853 | $(eval $(value def_link_common))
|
---|
[353] | 1854 |
|
---|
| 1855 | endef
|
---|
| 1856 |
|
---|
| 1857 | # Process build programs.
|
---|
| 1858 | EXT := EXE
|
---|
| 1859 | EXTPRE := HOST
|
---|
[380] | 1860 | tool_do := LINK_PROGRAM
|
---|
[353] | 1861 | definst := $(PATH_BIN)
|
---|
| 1862 | typevar := _BLDPROGS
|
---|
[380] | 1863 | mode := 0755
|
---|
[353] | 1864 | bld_trg_base_var := PLATFORM
|
---|
[481] | 1865 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), $(eval $(value def_bldprog)))
|
---|
[353] | 1866 |
|
---|
| 1867 |
|
---|
| 1868 |
|
---|
| 1869 | #
|
---|
| 1870 | # DLLS
|
---|
| 1871 | #
|
---|
| 1872 |
|
---|
[189] | 1873 | # Process dlls
|
---|
[353] | 1874 | EXT := DLL
|
---|
| 1875 | EXTPRE :=
|
---|
[380] | 1876 | tool_do := LINK_DLL
|
---|
[353] | 1877 | definst := $(PATH_DLL)
|
---|
| 1878 | typevar := _DLLS
|
---|
[380] | 1879 | mode := 0755
|
---|
[353] | 1880 | bld_trg_base_var := TARGET
|
---|
[481] | 1881 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
[74] | 1882 |
|
---|
| 1883 |
|
---|
[72] | 1884 | #
|
---|
[189] | 1885 | # Process import libraries.
|
---|
[72] | 1886 | #
|
---|
[219] | 1887 | # - On OS/2 and windows these are libraries.
|
---|
[189] | 1888 | # - On other platforms they are fake DLLs.
|
---|
[481] | 1889 | ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
|
---|
| 1890 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
---|
[189] | 1891 | else
|
---|
[481] | 1892 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
[189] | 1893 | endif
|
---|
[481] | 1894 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[353] | 1895 | $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
|
---|
[72] | 1896 |
|
---|
[189] | 1897 |
|
---|
| 1898 | #
|
---|
| 1899 | # PROGRAMS
|
---|
| 1900 | #
|
---|
| 1901 |
|
---|
[353] | 1902 | # Process programs
|
---|
| 1903 | EXT := EXE
|
---|
| 1904 | EXTPRE :=
|
---|
[380] | 1905 | tool_do := LINK_PROGRAM
|
---|
[353] | 1906 | definst := $(PATH_BIN)
|
---|
| 1907 | typevar := _PROGRAMS
|
---|
[380] | 1908 | mode := 0755
|
---|
[353] | 1909 | bld_trg_base_var := TARGET
|
---|
[481] | 1910 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
[130] | 1911 |
|
---|
| 1912 |
|
---|
[189] | 1913 |
|
---|
[72] | 1914 | #
|
---|
[83] | 1915 | # SYSMODS
|
---|
[72] | 1916 | #
|
---|
| 1917 |
|
---|
[130] | 1918 | # Process sysmods
|
---|
[353] | 1919 | EXT := SYS
|
---|
| 1920 | EXTPRE :=
|
---|
[380] | 1921 | tool_do := LINK_SYSMOD
|
---|
[353] | 1922 | definst := $(PATH_SYS)
|
---|
| 1923 | typevar := _SYSMODS
|
---|
[380] | 1924 | mode := 0644
|
---|
[353] | 1925 | bld_trg_base_var := TARGET
|
---|
[481] | 1926 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
[83] | 1927 |
|
---|
| 1928 |
|
---|
[72] | 1929 | #
|
---|
| 1930 | # OTHERS
|
---|
| 1931 | #
|
---|
[481] | 1932 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
[72] | 1933 |
|
---|
| 1934 |
|
---|
[353] | 1935 | #
|
---|
| 1936 | # INSTALLS
|
---|
| 1937 | #
|
---|
[72] | 1938 |
|
---|
[353] | 1939 | ## generate the install rule
|
---|
| 1940 | define def_install_src_rule
|
---|
| 1941 | # the install rule
|
---|
| 1942 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
[380] | 1943 | $$(if $$(filter $(INSTALL),$(inscmd)),,$$(RM) -f $$@)
|
---|
[353] | 1944 | $(inscmd)
|
---|
| 1945 | endef
|
---|
| 1946 |
|
---|
| 1947 | ## install one file
|
---|
| 1948 | define def_install_src
|
---|
| 1949 |
|
---|
| 1950 | # deal with '=>' in the source file name.
|
---|
| 1951 | srcdst := $(subst =>, ,$(src))
|
---|
| 1952 | srcsrc := $(firstword $(srcdst))
|
---|
[424] | 1953 | srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
[353] | 1954 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
| 1955 |
|
---|
| 1956 | # _INSTFUN
|
---|
| 1957 | ifdef $(srcsrc)_INSTFUN
|
---|
| 1958 | instfun := $(srcsrc)_INSTFUN
|
---|
| 1959 | else
|
---|
| 1960 | ifdef $(target)_INSTFUN
|
---|
| 1961 | instfun := $(target)_INSTFUN
|
---|
| 1962 | else
|
---|
| 1963 | instfun := _INSTALL_FILE
|
---|
| 1964 | endif
|
---|
| 1965 | endif
|
---|
| 1966 |
|
---|
| 1967 | # _INST
|
---|
| 1968 | ifdef $(srcsrc)_INST
|
---|
[424] | 1969 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
---|
[353] | 1970 | else
|
---|
| 1971 | ifdef $(target)_INST
|
---|
[424] | 1972 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
---|
[353] | 1973 | else
|
---|
[424] | 1974 | inst := $(dir $(srcdstdir))
|
---|
[353] | 1975 | endif
|
---|
| 1976 | endif
|
---|
| 1977 |
|
---|
| 1978 | # calc target
|
---|
[380] | 1979 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
[424] | 1980 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
---|
[353] | 1981 |
|
---|
[414] | 1982 | # mode, uid and gid
|
---|
| 1983 | mode := $(firstword \
|
---|
[481] | 1984 | $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 1985 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 1986 | $($(target)_$(srcsrc)_MODE) \
|
---|
[481] | 1987 | $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 1988 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
| 1989 | $($(target)_$(srcdst)_MODE) \
|
---|
[481] | 1990 | $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 1991 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 1992 | $($(srcsrc)_MODE) \
|
---|
[481] | 1993 | $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 1994 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
| 1995 | $($(srcdst)_MODE) \
|
---|
[481] | 1996 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 1997 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 1998 | $($(target)_MODE))
|
---|
| 1999 | uid := $(firstword \
|
---|
[481] | 2000 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2001 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
| 2002 | $($(target)_$(srcsrc)_UID) \
|
---|
[481] | 2003 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2004 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
| 2005 | $($(target)_$(srcdst)_UID) \
|
---|
[481] | 2006 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2007 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
| 2008 | $($(srcsrc)_UID) \
|
---|
[481] | 2009 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2010 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
| 2011 | $($(srcdst)_UID) \
|
---|
[481] | 2012 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2013 | $($(target)_UID.$(bld_trg)) \
|
---|
| 2014 | $($(target)_UID))
|
---|
| 2015 | gid := $(firstword \
|
---|
[481] | 2016 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2017 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
| 2018 | $($(target)_$(srcsrc)_GID) \
|
---|
[481] | 2019 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2020 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
| 2021 | $($(target)_$(srcdst)_GID) \
|
---|
[481] | 2022 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2023 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
| 2024 | $($(srcsrc)_GID) \
|
---|
[481] | 2025 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2026 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
| 2027 | $($(srcdst)_GID) \
|
---|
[481] | 2028 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2029 | $($(target)_GID.$(bld_trg)) \
|
---|
| 2030 | $($(target)_GID))
|
---|
| 2031 |
|
---|
[353] | 2032 | # create the command
|
---|
| 2033 | ifdef $(srcsrc)_INSTALLER
|
---|
| 2034 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
| 2035 | else
|
---|
| 2036 | ifdef $(target)_INSTALLER
|
---|
| 2037 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
| 2038 | else
|
---|
[414] | 2039 | inscmd := $$(INSTALL)\
|
---|
| 2040 | $(if $(uid),-o $(uid))\
|
---|
| 2041 | $(if $(gid),-g $(gid))\
|
---|
| 2042 | $(if $(mode),-m $(mode))\
|
---|
| 2043 | $(srcsrc) $(insdst)
|
---|
[353] | 2044 | endif
|
---|
| 2045 | endif
|
---|
| 2046 |
|
---|
| 2047 | # generate the rule (need double evaluation here)
|
---|
| 2048 | $(eval $(def_install_src_rule))
|
---|
| 2049 |
|
---|
| 2050 | INSTARGET_$(target) += $(insdst)
|
---|
| 2051 | endef
|
---|
| 2052 |
|
---|
| 2053 |
|
---|
| 2054 | ## generate the symlink rule
|
---|
| 2055 | define def_install_symlink_rule
|
---|
| 2056 | # the install rule
|
---|
| 2057 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
| 2058 | $$(RM) -f $$@
|
---|
[380] | 2059 | $$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
[353] | 2060 | endef
|
---|
| 2061 |
|
---|
| 2062 | ## create one symlink
|
---|
| 2063 | define def_install_symlink
|
---|
| 2064 |
|
---|
| 2065 | # deal with '=>' in the source file name.
|
---|
[380] | 2066 | symdst := $(subst =>, ,$(src))
|
---|
| 2067 | symlnk := $(firstword $(symdst))
|
---|
| 2068 | symdst := $(word $(words $(symdst)),$(symdst))
|
---|
[353] | 2069 |
|
---|
| 2070 | # _INSTFUN
|
---|
[380] | 2071 | ifdef $(symlnk)_INSTFUN
|
---|
| 2072 | instfun := $(symlnk)_INSTFUN
|
---|
[353] | 2073 | else
|
---|
| 2074 | ifdef $(target)_INSTFUN
|
---|
| 2075 | instfun := $(target)_INSTFUN
|
---|
| 2076 | else
|
---|
| 2077 | instfun := _INSTALL_FILE
|
---|
| 2078 | endif
|
---|
| 2079 | endif
|
---|
| 2080 |
|
---|
| 2081 | # _INST
|
---|
[380] | 2082 | ifdef $(symlnk)_INST
|
---|
| 2083 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
[353] | 2084 | else
|
---|
| 2085 | ifdef $(target)_INST
|
---|
[380] | 2086 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
[353] | 2087 | else
|
---|
[380] | 2088 | inst := $(dir $(symlnk))
|
---|
[353] | 2089 | endif
|
---|
| 2090 | endif
|
---|
| 2091 |
|
---|
| 2092 | # calc target
|
---|
[380] | 2093 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
| 2094 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
[353] | 2095 |
|
---|
| 2096 | # generate the rule (need double evaluation here)
|
---|
| 2097 | $(eval $(def_install_symlink_rule))
|
---|
| 2098 |
|
---|
| 2099 | INSTARGET_$(target) += $(insdst)
|
---|
| 2100 | endef
|
---|
| 2101 |
|
---|
[412] | 2102 |
|
---|
[380] | 2103 | ## generate the install rule
|
---|
| 2104 | define def_install_directory_rule
|
---|
| 2105 | # the install rule
|
---|
| 2106 | $(insdst):
|
---|
| 2107 | $(INSTALL) -d \
|
---|
| 2108 | $(if $(uid),-o $(uid))\
|
---|
| 2109 | $(if $(gid),-g $(gid))\
|
---|
| 2110 | $(if $(mode),-m $(mode))\
|
---|
| 2111 | $(insdst)
|
---|
[412] | 2112 |
|
---|
| 2113 | .NOTPARALLEL: $(insdst)
|
---|
[380] | 2114 | endef
|
---|
| 2115 |
|
---|
[412] | 2116 |
|
---|
[380] | 2117 | ## create one directory
|
---|
| 2118 | define def_install_directory
|
---|
| 2119 |
|
---|
| 2120 | # _INST
|
---|
| 2121 | ifdef $(directory)_INST
|
---|
| 2122 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
| 2123 | else
|
---|
| 2124 | ifdef $(target)_INST
|
---|
| 2125 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
| 2126 | else
|
---|
| 2127 | inst := $(PATH_INS)
|
---|
| 2128 | endif
|
---|
| 2129 | endif
|
---|
| 2130 |
|
---|
| 2131 | mode := $(firstword \
|
---|
[481] | 2132 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2133 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
| 2134 | $($(target)_$(directory)_MODE) \
|
---|
[481] | 2135 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2136 | $($(directory)_MODE.$(bld_trg)) \
|
---|
| 2137 | $($(directory)_MODE) \
|
---|
[481] | 2138 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2139 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 2140 | $($(target)_MODE))
|
---|
| 2141 | uid := $(firstword \
|
---|
[481] | 2142 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2143 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
| 2144 | $($(target)_$(directory)_UID) \
|
---|
[481] | 2145 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2146 | $($(directory)_UID.$(bld_trg)) \
|
---|
| 2147 | $($(directory)_UID) \
|
---|
[481] | 2148 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2149 | $($(target)_UID.$(bld_trg)) \
|
---|
| 2150 | $($(target)_UID))
|
---|
| 2151 | gid := $(firstword \
|
---|
[481] | 2152 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2153 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
| 2154 | $($(target)_$(directory)_GID) \
|
---|
[481] | 2155 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2156 | $($(directory)_GID.$(bld_trg)) \
|
---|
| 2157 | $($(directory)_GID) \
|
---|
[481] | 2158 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2159 | $($(target)_GID.$(bld_trg)) \
|
---|
| 2160 | $($(target)_GID))
|
---|
| 2161 |
|
---|
| 2162 | insdst := $(inst)/$(directory)/
|
---|
| 2163 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
| 2164 |
|
---|
| 2165 | # generate the rule (need double evaluation here)
|
---|
| 2166 | $(eval $(def_install_directory_rule))
|
---|
| 2167 |
|
---|
| 2168 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
| 2169 | endef
|
---|
| 2170 |
|
---|
| 2171 |
|
---|
[353] | 2172 | ## process one install target.
|
---|
| 2173 | define def_install
|
---|
| 2174 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 2175 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 2176 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 2177 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 2178 |
|
---|
| 2179 | INSTARGET_$(target) :=
|
---|
[380] | 2180 | INSTARGET_DIRS_$(target) :=
|
---|
| 2181 |
|
---|
[481] | 2182 | $(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \
|
---|
[380] | 2183 | $(eval $(value def_install_directory)))
|
---|
| 2184 |
|
---|
[481] | 2185 | $(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
|
---|
[353] | 2186 | $(eval $(value def_install_src)))
|
---|
| 2187 |
|
---|
[481] | 2188 | $(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
|
---|
[353] | 2189 | $(eval $(value def_install_symlink)))
|
---|
| 2190 |
|
---|
[380] | 2191 | _INSTALLS += $(INSTARGET_$(target)) $($(target)_GOALS)
|
---|
| 2192 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
[353] | 2193 | endef
|
---|
| 2194 |
|
---|
| 2195 | ## process all install targets
|
---|
[481] | 2196 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[353] | 2197 | $(eval $(value def_install)))
|
---|
| 2198 |
|
---|
| 2199 |
|
---|
[72] | 2200 | #
|
---|
[417] | 2201 | # PACKING
|
---|
| 2202 | #
|
---|
[481] | 2203 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET)) $(PACKING.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
[417] | 2204 |
|
---|
| 2205 |
|
---|
| 2206 | #
|
---|
[72] | 2207 | # DOCS
|
---|
| 2208 | #
|
---|
| 2209 |
|
---|
| 2210 |
|
---|
| 2211 | #
|
---|
[353] | 2212 | # DIRECTORIES
|
---|
| 2213 | #
|
---|
| 2214 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS)))
|
---|
[380] | 2215 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
[353] | 2216 |
|
---|
[380] | 2217 |
|
---|
[353] | 2218 | define def_mkdir_rule
|
---|
| 2219 | $(directory):
|
---|
| 2220 | $(call MSG_L1,Creating directory $$@)
|
---|
| 2221 | $(MKDIR) -p $$@
|
---|
[72] | 2222 | endef
|
---|
| 2223 |
|
---|
[353] | 2224 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
[72] | 2225 |
|
---|
[183] | 2226 |
|
---|
[72] | 2227 | #
|
---|
[353] | 2228 | # NOTHING
|
---|
[72] | 2229 | #
|
---|
[353] | 2230 | do-nothing:
|
---|
| 2231 | $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
[72] | 2232 |
|
---|
[183] | 2233 |
|
---|
[75] | 2234 | #
|
---|
[353] | 2235 | # CLEAN UP
|
---|
[75] | 2236 | #
|
---|
[353] | 2237 | do-clean:
|
---|
[380] | 2238 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
[72] | 2239 |
|
---|
[98] | 2240 |
|
---|
[353] | 2241 | #
|
---|
| 2242 | # PASSES (including directory and makefile walking)
|
---|
| 2243 | #
|
---|
[221] | 2244 |
|
---|
[75] | 2245 | ## Subdir
|
---|
| 2246 | # @param $(pass) Lowercase pass name.
|
---|
| 2247 | # @param $(PASS) Uppercase pass name.
|
---|
| 2248 | # @param $(subdir) Subdirectory
|
---|
| 2249 | # @param $(tag) tag to attach to the rule name.
|
---|
| 2250 | define def_pass_subdir
|
---|
[219] | 2251 | pass_$(pass)$(tag):: $(dep)
|
---|
| 2252 | + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
[75] | 2253 | endef
|
---|
[72] | 2254 |
|
---|
[75] | 2255 | ## Submakefile
|
---|
| 2256 | # @param $(pass) Lowercase pass name.
|
---|
| 2257 | # @param $(PASS) Uppercase pass name.
|
---|
| 2258 | # @param $(makefile) Makefile.
|
---|
| 2259 | # @param $(tag) tag to attach to the rule name.
|
---|
| 2260 | define def_pass_makefile
|
---|
[219] | 2261 | pass_$(pass)$(tag):: $(dep)
|
---|
| 2262 | + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
[75] | 2263 | endef
|
---|
[73] | 2264 |
|
---|
[75] | 2265 | ## Execute a pass.
|
---|
| 2266 | # @param $(pass) Lowercase pass name.
|
---|
| 2267 | # @param $(PASS) Uppercase pass name.
|
---|
[353] | 2268 | define def_pass_old
|
---|
[481] | 2269 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2270 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2271 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2272 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
[75] | 2273 |
|
---|
| 2274 | $(eval tag:=_before)
|
---|
[219] | 2275 | $(eval dep:=)
|
---|
[481] | 2276 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 2277 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
[75] | 2278 |
|
---|
| 2279 | $(eval tag:=_after)
|
---|
[219] | 2280 | $(eval dep:=pass_$(pass)_doit)
|
---|
[481] | 2281 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 2282 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 2283 |
|
---|
| 2284 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 2285 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
[353] | 2286 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
[272] | 2287 | pass_$(pass)_this: pass_$(pass)_before
|
---|
[220] | 2288 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
| 2289 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
[219] | 2290 | pass_$(pass): pass_$(pass)_after
|
---|
[75] | 2291 |
|
---|
[183] | 2292 | endef
|
---|
| 2293 |
|
---|
[353] | 2294 | define def_pass
|
---|
[481] | 2295 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET.$(BUILD_TARGET_ARCH))) )
|
---|
| 2296 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2297 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2298 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
[183] | 2299 |
|
---|
[353] | 2300 | $(eval tag:=_before)
|
---|
| 2301 | $(eval dep:=)
|
---|
[481] | 2302 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 2303 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
[75] | 2304 |
|
---|
[353] | 2305 | $(eval tag:=_after)
|
---|
| 2306 | $(eval dep:=pass_$(pass)_doit)
|
---|
[481] | 2307 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 2308 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 2309 |
|
---|
[380] | 2310 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 2311 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
| 2312 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
| 2313 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
| 2314 | pass_$(pass)_this: pass_$(pass)_before
|
---|
| 2315 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
| 2316 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
| 2317 | pass_$(pass): pass_$(pass)_after
|
---|
| 2318 | else
|
---|
[388] | 2319 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
[353] | 2320 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
| 2321 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
| 2322 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
| 2323 | pass_$(pass): \
|
---|
| 2324 | pass_$(pass)_before \
|
---|
| 2325 | pass_$(pass)_doit \
|
---|
[388] | 2326 | pass_$(pass)_after
|
---|
[353] | 2327 | endif
|
---|
[189] | 2328 |
|
---|
[353] | 2329 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
| 2330 | endef
|
---|
[75] | 2331 |
|
---|
[353] | 2332 | # Generate the defined passes.
|
---|
| 2333 | $(foreach PASS, $(PASSES), \
|
---|
| 2334 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 2335 | $(eval $(def_pass)))
|
---|
[75] | 2336 |
|
---|
[219] | 2337 | ## Pass order
|
---|
| 2338 | # @param $(pass) Current pass name.
|
---|
| 2339 | # @param $(prev_pass) The previous pass name.
|
---|
| 2340 | define def_pass_order
|
---|
[380] | 2341 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 2342 | .NOTPARALLEL: pass_$(pass)_order
|
---|
| 2343 | .PHONY: pass_$(pass)_order
|
---|
[219] | 2344 | pass_$(pass)_order: $(pass_prev)
|
---|
[353] | 2345 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
[219] | 2346 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
[353] | 2347 | else
|
---|
| 2348 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
[388] | 2349 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
[353] | 2350 | pass_$(pass)_banner:
|
---|
| 2351 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
| 2352 | pass_$(pass)_order: \
|
---|
| 2353 | $(pass_prev) \
|
---|
| 2354 | pass_$(pass)_banner \
|
---|
| 2355 | pass_$(pass)
|
---|
| 2356 | endif
|
---|
[219] | 2357 | $(eval pass_prev := pass_$(pass)_order)
|
---|
| 2358 | endef
|
---|
[183] | 2359 |
|
---|
[219] | 2360 | ## PASS: order
|
---|
| 2361 | # Use dependencies to ensure correct pass order.
|
---|
| 2362 | pass_prev :=
|
---|
[353] | 2363 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
| 2364 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 2365 | $(eval $(def_pass_order)))
|
---|
[219] | 2366 |
|
---|
[272] | 2367 |
|
---|
[75] | 2368 | #
|
---|
| 2369 | # THE MAIN RULES
|
---|
| 2370 | #
|
---|
[219] | 2371 | all_recursive: $(pass_prev)
|
---|
[75] | 2372 |
|
---|
[130] | 2373 | rebuild: clean
|
---|
[219] | 2374 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
[78] | 2375 |
|
---|
[412] | 2376 | # @todo make this a non-default pass!
|
---|
[353] | 2377 | uninstall:
|
---|
| 2378 | $(RM) -f $(_INSTALLS)
|
---|
[412] | 2379 |
|
---|
[380] | 2380 | install: pass_installs
|
---|
[78] | 2381 |
|
---|
[75] | 2382 | # misc shortcuts.
|
---|
[380] | 2383 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
[75] | 2384 | objects: $(_OBJS)
|
---|
[222] | 2385 | bldprogs: $(_BLDPROGS)
|
---|
[189] | 2386 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
[205] | 2387 | dlls: $(_DLLS)
|
---|
[219] | 2388 | programs: $(_PROGRAMS)
|
---|
[205] | 2389 | sysmods: $(_SYSMODS)
|
---|
[353] | 2390 | others: $(_OTHERS)
|
---|
[380] | 2391 | installs: $(_INSTALLS_DIRS) $(_INSTALLS)
|
---|
[75] | 2392 |
|
---|
| 2393 |
|
---|
[353] | 2394 | #
|
---|
| 2395 | # kBuild debugging stuff.
|
---|
| 2396 | #
|
---|
| 2397 | _SPACE := $(subst ., ,.)
|
---|
| 2398 | _TAB := $(subst ., ,.)
|
---|
| 2399 | define _NEWLINE
|
---|
| 2400 |
|
---|
| 2401 |
|
---|
| 2402 | endef
|
---|
| 2403 | NLTAB = $(_NEWLINE)$(TAB)
|
---|
| 2404 | show_targets:
|
---|
| 2405 | @$(foreach target, $(ALL_TARGETS),\
|
---|
| 2406 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
| 2407 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
| 2408 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
| 2409 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
[660] | 2410 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) OBJS_ CLEAN, \
|
---|
[353] | 2411 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 2412 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
| 2413 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
| 2414 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
| 2415 | )\
|
---|
| 2416 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
| 2417 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 2418 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
| 2419 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
| 2420 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
| 2421 | ))
|
---|
| 2422 |
|
---|
| 2423 |
|
---|
| 2424 |
|
---|
| 2425 | #
|
---|
| 2426 | # Include dependency files.
|
---|
| 2427 | #
|
---|
| 2428 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
| 2429 |
|
---|
| 2430 |
|
---|
[72] | 2431 | # end-of-file-content
|
---|
[106] | 2432 | __footer_kmk__ := target
|
---|
[72] | 2433 | endif # __footer_kmk__
|
---|
[438] | 2434 |
|
---|