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