[72] | 1 | # $Id: footer.kmk 447 2006-06-05 16:22:01Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
[353] | 6 | # Copyright (c) 2004-2005 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 | #
|
---|
| 31 | # Variables.
|
---|
[73] | 32 | # (Some of these need initialization before including definitions using them.)
|
---|
[72] | 33 | #
|
---|
| 34 |
|
---|
| 35 | # all targets.
|
---|
[353] | 36 | ALL_TARGETS += \
|
---|
[239] | 37 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) \
|
---|
[189] | 38 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
|
---|
| 39 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) \
|
---|
| 40 | $(DLLS) $(DLLS.$(BUILD_TARGET)) \
|
---|
| 41 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
|
---|
| 42 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
|
---|
[353] | 43 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) \
|
---|
[189] | 44 | $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
[72] | 45 |
|
---|
[447] | 46 | # all $(BUILD_TARGET) targets.
|
---|
| 47 | _ALL_BUILD_TARGET_TARGETS += \
|
---|
| 48 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) \
|
---|
| 49 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
|
---|
| 50 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) \
|
---|
| 51 | $(DLLS) $(DLLS.$(BUILD_TARGET)) \
|
---|
| 52 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
|
---|
| 53 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
|
---|
| 54 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) \
|
---|
| 55 | $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
| 56 |
|
---|
| 57 | # all $(BUILD_TARGET) targets.
|
---|
| 58 | _ALL_BUILD_PLATFORM_TARGETS += \
|
---|
| 59 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM))
|
---|
| 60 |
|
---|
[75] | 61 | # dependency files.
|
---|
| 62 | _DEPFILES :=
|
---|
| 63 |
|
---|
[380] | 64 | # included dependency files.
|
---|
| 65 | _DEPFILES_INCLUDED :=
|
---|
| 66 |
|
---|
| 67 |
|
---|
[75] | 68 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
| 69 | # Compiling or linking definition outputting other things that $@ and any
|
---|
| 70 | # required dependency file must add those output files to this variable.
|
---|
| 71 | _OUT_FILES :=
|
---|
| 72 |
|
---|
[353] | 73 | # Files which only requires cleaning up.
|
---|
| 74 | _CLEAN_FILES :=
|
---|
| 75 |
|
---|
[72] | 76 | # all of a type
|
---|
[219] | 77 | _OBJS :=
|
---|
[222] | 78 | _BLDPROGS :=
|
---|
[219] | 79 | _LIBS :=
|
---|
| 80 | _DLLS :=
|
---|
| 81 | _PROGRAMS :=
|
---|
| 82 | _SYSMODS :=
|
---|
[353] | 83 | _INSTALLS :=
|
---|
[380] | 84 | _INSTALLS_DIRS :=
|
---|
[353] | 85 | _OTHERS :=
|
---|
[417] | 86 | _PACKING :=
|
---|
[380] | 87 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET)
|
---|
[189] | 88 | _IMPORT_LIBS :=
|
---|
[72] | 89 |
|
---|
[220] | 90 | # misc
|
---|
| 91 | pass_prev :=
|
---|
| 92 |
|
---|
| 93 |
|
---|
[72] | 94 | #
|
---|
[73] | 95 | # Basic macros
|
---|
| 96 | #
|
---|
| 97 |
|
---|
| 98 | ## Figure out the tool for a source
|
---|
[106] | 99 | # @param $target source file
|
---|
| 100 | # @param $source normalized main target
|
---|
| 101 | # @param $type tooltype
|
---|
[222] | 102 | # @param bld_trg build target.
|
---|
[79] | 103 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
[222] | 104 | $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 105 | $($(target)_$(source)_$(type)TOOL) \
|
---|
[222] | 106 | $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
[106] | 107 | $($(target)_$(source)_TOOL) \
|
---|
[222] | 108 | $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 109 | $($(target)_$(type)TOOL) \
|
---|
[222] | 110 | $($(target)_TOOL.$(bld_trg)) \
|
---|
[106] | 111 | $($(target)_TOOL) \
|
---|
[222] | 112 | $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 113 | $($(source)_$(type)TOOL) \
|
---|
[222] | 114 | $($(source)_TOOL.$(bld_trg)) \
|
---|
[106] | 115 | $($(source)_TOOL) \
|
---|
[222] | 116 | $($(type)TOOL.$(bld_trg)) \
|
---|
[106] | 117 | $($(type)TOOL) \
|
---|
[222] | 118 | $(TOOL.$(bld_trg)) \
|
---|
[106] | 119 | $(TOOL) ))
|
---|
[73] | 120 |
|
---|
[78] | 121 | ## Figure out the tool for a target.
|
---|
[106] | 122 | # @param $target normalized target.
|
---|
| 123 | # @param $source tooltype.
|
---|
[222] | 124 | # @param bld_trg build target.
|
---|
[79] | 125 | _TARGET_TOOL = $(strip $(firstword \
|
---|
[222] | 126 | $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
[106] | 127 | $($(target)_$(source)TOOL) \
|
---|
[222] | 128 | $($(target)_TOOL.$(bld_trg)) \
|
---|
[106] | 129 | $($(target)_TOOL) \
|
---|
[238] | 130 | $($(source)TOOL.$(bld_trg)) \
|
---|
[106] | 131 | $($(source)TOOL) \
|
---|
[222] | 132 | $(TOOL.$(bld_trg)) \
|
---|
[106] | 133 | $(TOOL) \
|
---|
[79] | 134 | ))
|
---|
[183] | 135 |
|
---|
[148] | 136 | ## Removes the drive letter from a path (if it has one)
|
---|
| 137 | # @param $1 the path
|
---|
| 138 | no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
[78] | 139 |
|
---|
[148] | 140 | ## Removes the root slash from a path (if it has one)
|
---|
| 141 | # @param $1 the path
|
---|
| 142 | no-root-slash=$(patsubst /%,%,$(1))
|
---|
| 143 |
|
---|
[73] | 144 | ## Figure out where to put object files.
|
---|
[110] | 145 | # @param $1 source file
|
---|
| 146 | # @param $2 normalized main target
|
---|
[316] | 147 | # @remark There are two major hacks here:
|
---|
| 148 | # 1. Source files in the output directory are translated into a gen/ subdir.
|
---|
| 149 | # 2. Catch anyone specifying $(PATH_CURRENT)/sourcefile.c.
|
---|
| 150 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename \
|
---|
| 151 | $(patsubst $(PATH_ROOT)/%,%,$(patsubst $(PATH_CURRENT)/%,%,$(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))))
|
---|
[73] | 152 |
|
---|
| 153 | ## Figure out where to put object files.
|
---|
[110] | 154 | # @param $1 real target name.
|
---|
| 155 | # @param $2 normalized main target
|
---|
[148] | 156 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
|
---|
[73] | 157 |
|
---|
| 158 |
|
---|
[353] | 159 | ## Figure out the actual name of an installed file.
|
---|
| 160 | # @param $1 The file to install.
|
---|
| 161 | # @param $2 The target name.
|
---|
| 162 | # @param $3 The _INST value (can be empty).
|
---|
| 163 | # @param $4 The default directory to use when $3 is empty.
|
---|
| 164 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
---|
| 165 |
|
---|
| 166 |
|
---|
[73] | 167 | #
|
---|
[185] | 168 | # Check syntax which leads to weird syntax errors.
|
---|
| 169 | #
|
---|
| 170 |
|
---|
| 171 | ## Check
|
---|
| 172 | # @param $(target) Target name.
|
---|
| 173 | define def_check_target
|
---|
| 174 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
| 175 | $$(error $(target) have an incorrect template name. Remove any tabs!)
|
---|
| 176 | endif
|
---|
| 177 | endef
|
---|
| 178 | $(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
|
---|
| 179 |
|
---|
| 180 |
|
---|
| 181 | #
|
---|
[72] | 182 | # Include templates
|
---|
| 183 | #
|
---|
| 184 | _TEMPLATES := $(TEMPLATE)
|
---|
| 185 | define def_templates
|
---|
| 186 | ifdef $(target)_TEMPLATE
|
---|
| 187 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
| 188 | endif
|
---|
| 189 | endef
|
---|
| 190 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
| 191 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
| 192 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
| 193 |
|
---|
| 194 | define def_templates_include
|
---|
| 195 | ifndef TEMPLATE_$(template)
|
---|
[353] | 196 | include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
|
---|
[72] | 197 | endif
|
---|
| 198 | endef
|
---|
| 199 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
| 200 |
|
---|
[74] | 201 |
|
---|
[72] | 202 | #
|
---|
[412] | 203 | # Template Inheritance.
|
---|
| 204 | #
|
---|
| 205 | define def_template_extends_prop
|
---|
| 206 | ifndef TEMPLATE_$(template)_$(prop)
|
---|
| 207 | ifdef TEMPLATE_$(parent)_$(prop)
|
---|
| 208 | TEMPLATE_$(template)_$(prop) = $$(TEMPLATE_$(parent)_$(prop))
|
---|
| 209 | endif
|
---|
| 210 | endif
|
---|
| 211 | endef
|
---|
| 212 |
|
---|
| 213 | define def_template_extends
|
---|
| 214 | ifdef TEMPLATE_$(template)_EXTENDS
|
---|
| 215 | parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
|
---|
| 216 |
|
---|
| 217 | $(foreach prop, $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED)\
|
---|
| 218 | $(addsuffix .$(BUILD_TARGET), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
|
---|
| 219 | $(addsuffix .$(BUILD_TYPE), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
|
---|
| 220 | ,$(eval $(def_template_extends_prop))) # exploits the 2 evaluation, so no value!
|
---|
| 221 | endif
|
---|
| 222 | endef
|
---|
| 223 |
|
---|
| 224 | # $ (foreach template, $(_TEMPLATES), $(if TEMPLATE_$(template)_EXTENDS, $(eval $(value def_template_extends))))
|
---|
| 225 | $(foreach template, $(_TEMPLATES), $(eval $(value def_template_extends)))
|
---|
| 226 |
|
---|
| 227 |
|
---|
| 228 | #
|
---|
[72] | 229 | # Common Inheritance
|
---|
| 230 | #
|
---|
| 231 |
|
---|
| 232 | ## Inherit defaults property
|
---|
| 233 | # @param $(prop) Property name
|
---|
| 234 | # @param $(target) Target name.
|
---|
[447] | 235 | # @param $(bld_trg) Build target name.
|
---|
[72] | 236 | define def_inherit_defaults_one
|
---|
[74] | 237 | ifndef $(target)_$(prop)
|
---|
[447] | 238 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
[72] | 239 | ifdef $(prop)
|
---|
[105] | 240 | $$(eval $(target)_$(prop) := $($(prop)))
|
---|
[447] | 241 | #$ (warning dbg idefone: $(target)_$(prop):=$($(prop)))
|
---|
[72] | 242 | endif
|
---|
[447] | 243 | ifdef $(prop).$(bld_trg)
|
---|
| 244 | $$(eval $(target)_$(prop).$(bld_trg) := $($(prop).$(bld_trg)))
|
---|
| 245 | #$ (warning dbg idefone: $(target)_$(prop).$(bld_trg) := $($(prop).$(bld_trg)))
|
---|
[72] | 246 | endif
|
---|
[109] | 247 | endif
|
---|
| 248 | endif
|
---|
[72] | 249 | endef
|
---|
| 250 |
|
---|
| 251 | ## Inherit default properties for one target.
|
---|
| 252 | # A bit tricky this one, but it depends a bit on whether or not TEMPLATE
|
---|
| 253 | # is inherited from the default properties.
|
---|
| 254 | # @param $(target) Target name
|
---|
[447] | 255 | # @param $(bld_trg) Build target name.
|
---|
[78] | 256 | #
|
---|
[72] | 257 | define def_inherit_defaults
|
---|
| 258 | ifdef $(target)_TEMPLATE
|
---|
[447] | 259 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(bld_trg))),)
|
---|
[109] | 260 | $$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 261 | endif
|
---|
[447] | 262 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(bld_trg))),)
|
---|
[109] | 263 | $$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 264 | endif
|
---|
| 265 | else
|
---|
[109] | 266 | $$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
[72] | 267 | endif
|
---|
| 268 | endef
|
---|
| 269 | # Inherit default properties.
|
---|
[109] | 270 | # !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
|
---|
[447] | 271 | #bld_trg := $(BUILD_TARGET)
|
---|
| 272 | #$(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(def_inherit_defaults)))
|
---|
| 273 | #bld_trg := $(BUILD_PLATFORM)
|
---|
| 274 | #$(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(def_inherit_defaults)))
|
---|
[72] | 275 |
|
---|
| 276 |
|
---|
[353] | 277 | ## Inherit one template property in a non-accumulative manner.
|
---|
[72] | 278 | # @param $(prop) Property name
|
---|
| 279 | # @param $(target) Target name
|
---|
[78] | 280 | # @todo fix the precedence order for some properties.
|
---|
[72] | 281 | define def_inherit_template_one
|
---|
[78] | 282 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[72] | 283 | ifndef $(target)_$(prop)
|
---|
[353] | 284 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 285 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[72] | 286 | endif
|
---|
| 287 | endif
|
---|
[447] | 288 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 289 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
| 290 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 291 | $(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[79] | 292 | endif
|
---|
| 293 | endif
|
---|
[72] | 294 | endef
|
---|
| 295 |
|
---|
[353] | 296 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
| 297 | # @param 1: $(prop) Property name
|
---|
| 298 | # @param 2: $(target) Target name
|
---|
| 299 | # @todo fix the precedence order for some properties.
|
---|
| 300 | # @remark this define relies on double evaluation
|
---|
| 301 | define def_inherit_template_one_deferred
|
---|
| 302 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
| 303 | ifndef $(target)_$(prop)
|
---|
| 304 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 305 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 306 | endif
|
---|
| 307 | endif
|
---|
[447] | 308 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 309 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
| 310 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 311 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[353] | 312 | endif
|
---|
| 313 | endif
|
---|
| 314 | endef
|
---|
| 315 |
|
---|
[183] | 316 | ## Inherit one template property.
|
---|
[78] | 317 | # @param $(prop) Property name
|
---|
| 318 | # @param $(target) Target name
|
---|
| 319 | define def_inherit_template_one_accumulate
|
---|
| 320 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[353] | 321 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
[442] | 322 | $(target)_$(prop) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 323 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
[78] | 324 | endif
|
---|
[243] | 325 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
[353] | 326 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[442] | 327 | $(target)_$(prop).$(BUILD_TYPE) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[243] | 328 | endif
|
---|
[447] | 329 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 330 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 331 | $(target)_$(prop).$(bld_trg) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[79] | 332 | endif
|
---|
[447] | 333 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 334 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 335 | $(target)_$(prop).$(bld_trg_cpu) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
[79] | 336 | endif
|
---|
[447] | 337 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 338 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 339 | $(target)_$(prop).$(bld_trg_arch) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
[79] | 340 | endif
|
---|
[78] | 341 | endef
|
---|
| 342 |
|
---|
[72] | 343 | ## Inherit template properties for on target.
|
---|
| 344 | # @param $(target) Target name.
|
---|
| 345 | define def_inherit_template
|
---|
[447] | 346 | # Inherit any default template.
|
---|
| 347 | ifdef TEMPLATE
|
---|
| 348 | ifeq ($($(target)_TEMPLATE),)
|
---|
| 349 | $(eval $(target)_TEMPLATE:=$(TEMPLATE))
|
---|
| 350 | endif
|
---|
| 351 | endif
|
---|
| 352 | # Expand the template if specified.
|
---|
| 353 | ifneq ($($(target)_TEMPLATE),)
|
---|
[353] | 354 | $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
|
---|
| 355 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
---|
[442] | 356 | $(foreach prop,$(PROPS_ACCUMULATE),$(eval $(def_inherit_template_one_accumulate))) # += works fine (better) without value.
|
---|
[447] | 357 | endif
|
---|
[72] | 358 | endef
|
---|
[353] | 359 |
|
---|
[72] | 360 | # Inherit template properties
|
---|
[447] | 361 | bld_trg := $(BUILD_TARGET)
|
---|
| 362 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 363 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
| 364 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(value def_inherit_template)))
|
---|
[72] | 365 |
|
---|
[447] | 366 | bld_trg := $(BUILD_PLATFORM)
|
---|
| 367 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
| 368 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
| 369 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(value def_inherit_template)))
|
---|
[72] | 370 |
|
---|
[447] | 371 |
|
---|
[72] | 372 | #
|
---|
| 373 | # Include tools
|
---|
[183] | 374 | #
|
---|
[72] | 375 | _TOOLS := $(TOOL)
|
---|
| 376 | define def_tools_target_source
|
---|
[353] | 377 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
| 378 | $($(source)_$(prop).$(BUILD_TARGET)) \
|
---|
| 379 | $($(target)_$(source)_$(prop).$(BUILD_TARGET)) \
|
---|
| 380 | $($(source)_$(prop)) \
|
---|
| 381 | $($(target)_$(source)_$(prop))))
|
---|
[72] | 382 | endef
|
---|
[353] | 383 |
|
---|
[72] | 384 | define def_tools_target
|
---|
[353] | 385 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
| 386 | $($(target)_$(prop).$(BUILD_TARGET)) \
|
---|
| 387 | $($(target)_$(prop))))
|
---|
| 388 | $(foreach source, \
|
---|
| 389 | $($(target)_SOURCES.$(BUILD_TARGET)) \
|
---|
| 390 | $($(target)_SOURCES.$(BUILD_TYPE)) \
|
---|
| 391 | $($(target)_SOURCES) \
|
---|
| 392 | , $(eval $(value def_tools_target_source)))
|
---|
[72] | 393 | endef
|
---|
[353] | 394 |
|
---|
| 395 | $(foreach target, $(ALL_TARGETS), $(eval $(value def_tools_target)))
|
---|
[72] | 396 | _TOOLS := $(sort $(_TOOLS))
|
---|
| 397 |
|
---|
| 398 | define def_tools_include
|
---|
| 399 | ifndef TOOL_$(tool)
|
---|
[353] | 400 | TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
|
---|
| 401 | ifeq ($(TOOL_$(tool)_KMK_FILE),)
|
---|
| 402 | $(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
|
---|
[72] | 403 | endif
|
---|
[353] | 404 | include $(TOOL_$(tool)_KMK_FILE)
|
---|
| 405 | endif
|
---|
[72] | 406 | endef
|
---|
[353] | 407 | $(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
|
---|
[72] | 408 |
|
---|
| 409 |
|
---|
| 410 | #
|
---|
| 411 | # Include SDKs
|
---|
[73] | 412 | #
|
---|
[72] | 413 | _SDKS := $(SDKS)
|
---|
| 414 | define def_sdks_target_source
|
---|
[220] | 415 | $(foreach sdk, $($(source)_SDKS) $($(source)_SDKS.$(BUILD_TARGET)) $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 416 | $($(target)_$(source)_SDKS) $($(target)_$(source)_SDKS.$(BUILD_TARGET)) $($(target)_$(source)_SDKS.$(BUILD_TYPE)), \
|
---|
[72] | 417 | $(eval _SDKS += $(sdk)))
|
---|
| 418 | endef
|
---|
| 419 | define def_sdks_target
|
---|
[220] | 420 | $(foreach sdk, $($(target)_SDKS) $($(target)_SDKS.$(BUILD_TARGET)) $($(target)_SDKS.$(BUILD_TYPE))\
|
---|
[122] | 421 | , $(eval _SDKS += $(sdk)))
|
---|
[220] | 422 | $(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TYPE))\
|
---|
[120] | 423 | , $(eval $(def_sdks_target_source)))
|
---|
[72] | 424 | endef
|
---|
| 425 | $(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
|
---|
| 426 | _SDKS := $(sort $(_SDKS))
|
---|
| 427 |
|
---|
[122] | 428 | define def_sdks_include_one
|
---|
[72] | 429 | ifndef SDK_$(sdk)
|
---|
[353] | 430 | SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
|
---|
| 431 | ifeq ($(SDK_$(sdk)_KMK_FILE),)
|
---|
| 432 | $(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
|
---|
[72] | 433 | endif
|
---|
[353] | 434 | include $(SDK_$(sdk)_KMK_FILE)
|
---|
| 435 | endif
|
---|
[72] | 436 | endef
|
---|
[353] | 437 | $(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
|
---|
[72] | 438 |
|
---|
[380] | 439 |
|
---|
[73] | 440 | #
|
---|
| 441 | # Object processing.
|
---|
| 442 | #
|
---|
[72] | 443 |
|
---|
[380] | 444 | ## wrapper the compile command dependency check.
|
---|
| 445 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
| 446 | _DEP_COMPILE_CMDS = $(if $(subst $(strip $($(target)_$(source)_CMDS_PREV_)),,$(strip $($(target)_$(source)_CMDS_))),FORCE,)
|
---|
| 447 | else
|
---|
| 448 | _DEP_COMPILE_CMDS =
|
---|
| 449 | endif
|
---|
| 450 |
|
---|
| 451 | ## Generates the rules for building a specific object, and the '::' aliases
|
---|
| 452 | # for building a source file.
|
---|
[353] | 453 | # @param $(obj) The object file.
|
---|
[380] | 454 | define def_target_source_rule
|
---|
| 455 | $(obj) $($(target)_$(source)_OUTPUT_): \
|
---|
| 456 | $($(target)_$(source)_DEPEND_) \
|
---|
| 457 | $(_DEP_COMPILE_CMDS) \
|
---|
| 458 | | \
|
---|
| 459 | $($(target)_$(source)_DEPORD_)
|
---|
| 460 | $(call MSG_L1,Creating $$@)
|
---|
| 461 | $(RM) -f $(dep) $(out) $($(target)_$(source)_OUTPUT_)
|
---|
| 462 | $(custom_pre)
|
---|
[412] | 463 |
|
---|
[380] | 464 | $($(target)_$(source)_CMDS_)
|
---|
| 465 |
|
---|
| 466 | $(custom_post)
|
---|
| 467 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
| 468 | @$(APPEND) "$(dep)"
|
---|
| 469 | @$(APPEND) "$(dep)" 'define $(target)_$(source)_CMDS_PREV_'
|
---|
| 470 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_$(source)_CMDS_))'
|
---|
| 471 | @$(APPEND) "$(dep)" 'endef'
|
---|
[412] | 472 | endif
|
---|
[380] | 473 |
|
---|
[353] | 474 | $(basename $(notdir $(obj))).o::
|
---|
[442] | 475 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
[445] | 476 | $(basename $(notdir $(obj))).obj::
|
---|
[442] | 477 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
[353] | 478 | endef
|
---|
[205] | 479 |
|
---|
[353] | 480 |
|
---|
[380] | 481 | ## wrapper the link command dependency check.
|
---|
| 482 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
| 483 | _DEP_LINK_CMDS = $(if $(subst $(strip $($(target)_CMDS_PREV_)),,$(strip $($(target)_CMDS_))),FORCE,)
|
---|
| 484 | else
|
---|
| 485 | _DEP_LINK_CMDS =
|
---|
| 486 | endif
|
---|
| 487 |
|
---|
| 488 | ## Generate the link rule for a target.
|
---|
| 489 | # @param $(target) The normalized target name.
|
---|
| 490 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
| 491 | # @param $(dep) The name of the dependency file.
|
---|
| 492 | # @param $(out)
|
---|
| 493 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
| 494 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
| 495 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
| 496 | # @param $($(target)_CMDS_) The link commands.
|
---|
| 497 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
| 498 | define def_link_rule
|
---|
| 499 | $(out) $($(target)_OUTPUT_): \
|
---|
| 500 | $($(target)_DEPEND_) \
|
---|
| 501 | $(_DEP_LINK_CMDS) \
|
---|
| 502 | | \
|
---|
| 503 | $($(target)_DEPORD_)
|
---|
| 504 | $(call MSG_L1,Creating $$@)
|
---|
| 505 | $(RM) -f $(dep) $($(target)_OUTPUT_)
|
---|
| 506 | $(custom_pre)
|
---|
[412] | 507 |
|
---|
[380] | 508 | $($(target)_CMDS_)
|
---|
| 509 |
|
---|
| 510 | $(custom_post)
|
---|
| 511 | ifndef NO_LINK_CMDS_DEP
|
---|
| 512 | @$(APPEND) "$(dep)" 'define $(target)_CMDS_PREV_'
|
---|
| 513 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_CMDS_))'
|
---|
| 514 | @$(APPEND) "$(dep)" 'endef'
|
---|
[412] | 515 | endif
|
---|
[380] | 516 |
|
---|
| 517 | $(basename $(notdir $(out)))::
|
---|
[442] | 518 | + $$(MAKE) -f $$(MAKEFILE) $(out)
|
---|
[380] | 519 | endef
|
---|
| 520 |
|
---|
| 521 |
|
---|
| 522 | ## Generate the link & lib install rule
|
---|
| 523 | # @param $(target) Normalized target name.
|
---|
| 524 | # @param $(out) The build target.
|
---|
| 525 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
| 526 | # @param $(mode) The file mode (optional)
|
---|
| 527 | define def_link_install_rule
|
---|
| 528 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
| 529 | $(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
| 530 | endef
|
---|
| 531 |
|
---|
| 532 |
|
---|
| 533 |
|
---|
[73] | 534 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 535 | # @param $(target) Normalized target name.
|
---|
| 536 | # @param $(source) Source file name.
|
---|
| 537 | # @param $(type) Source type. {C,CXX,AS}
|
---|
[221] | 538 | # @param bld_type Build type.
|
---|
| 539 | # @param bld_trg Build target.
|
---|
| 540 | # @param bld_trg_arch Build target arch.
|
---|
| 541 | # @param bld_trg_cpu Build target cpu.
|
---|
[72] | 542 | #
|
---|
[73] | 543 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
[105] | 544 | # @remark I now have a clue. Have to use $$ if not.
|
---|
[73] | 545 | define def_target_source_c_cpp_asm
|
---|
[105] | 546 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
[73] | 547 |
|
---|
[353] | 548 | tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
|
---|
| 549 | outbase := $(call _OBJECT_BASE,$(source),$(target))
|
---|
| 550 | PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 551 | dirdep := $(call DIRDEP,$(dir $(outbase)))
|
---|
| 552 | defs :=\
|
---|
[78] | 553 | $(TOOL_$(tool)_DEFS)\
|
---|
[221] | 554 | $(TOOL_$(tool)_DEFS.$(bld_type))\
|
---|
| 555 | $(TOOL_$(tool)_DEFS.$(bld_trg))\
|
---|
| 556 | $(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
|
---|
| 557 | $(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
|
---|
[74] | 558 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
[221] | 559 | $(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
|
---|
| 560 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
| 561 | $(SDKS.$(bld_type)) \
|
---|
[78] | 562 | $(SDKS),\
|
---|
[353] | 563 | $(SDK_$(sdk)_DEFS)\
|
---|
| 564 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 565 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 566 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
| 567 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 568 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 569 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 570 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 571 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 572 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 573 | $(DEFS)\
|
---|
[221] | 574 | $(DEFS.$(bld_type))\
|
---|
| 575 | $(DEFS.$(bld_trg))\
|
---|
| 576 | $(DEFS.$(bld_trg_arch))\
|
---|
| 577 | $(DEFS.$(bld_trg_cpu))\
|
---|
[78] | 578 | $($(type)DEFS)\
|
---|
[221] | 579 | $($(type)DEFS.$(bld_type))\
|
---|
| 580 | $($(type)DEFS.$(bld_trg))\
|
---|
| 581 | $($(type)DEFS.$(bld_trg_arch))\
|
---|
| 582 | $($(type)DEFS.$(bld_trg_cpu))\
|
---|
| 583 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
| 584 | $($(target)_SDKS.$(bld_type)) \
|
---|
[78] | 585 | $($(target)_SDKS),\
|
---|
[353] | 586 | $(SDK_$(sdk)_DEFS)\
|
---|
| 587 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 588 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 589 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
| 590 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 591 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 592 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 593 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 594 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 595 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 596 | $($(target)_DEFS)\
|
---|
[221] | 597 | $($(target)_DEFS.$(bld_type))\
|
---|
| 598 | $($(target)_DEFS.$(bld_trg))\
|
---|
| 599 | $($(target)_DEFS.$(bld_trg_arch))\
|
---|
| 600 | $($(target)_DEFS.$(bld_trg_cpu))\
|
---|
[78] | 601 | $($(target)_$(type)DEFS)\
|
---|
[221] | 602 | $($(target)_$(type)DEFS.$(bld_type))\
|
---|
| 603 | $($(target)_$(type)DEFS.$(bld_trg))\
|
---|
| 604 | $($(target)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 605 | $($(target)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
| 606 | $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
|
---|
| 607 | $($(source)_SDKS.$(bld_type)) \
|
---|
[78] | 608 | $($(source)_SDKS),\
|
---|
[353] | 609 | $(SDK_$(sdk)_DEFS)\
|
---|
| 610 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 611 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 612 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
| 613 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 614 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 615 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 616 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 617 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 618 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 619 | $($(source)_DEFS)\
|
---|
[221] | 620 | $($(source)_DEFS.$(bld_type))\
|
---|
| 621 | $($(source)_DEFS.$(bld_trg))\
|
---|
| 622 | $($(source)_DEFS.$(bld_trg_arch))\
|
---|
| 623 | $($(source)_DEFS.$(bld_trg_cpu))\
|
---|
[73] | 624 | $($(source)_$(type)DEFS)\
|
---|
[221] | 625 | $($(source)_$(type)DEFS.$(bld_type))\
|
---|
| 626 | $($(source)_$(type)DEFS.$(bld_trg))\
|
---|
| 627 | $($(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 628 | $($(source)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
| 629 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
| 630 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
[78] | 631 | $($(target)_$(source)_SDKS),\
|
---|
[353] | 632 | $(SDK_$(sdk)_DEFS)\
|
---|
| 633 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 634 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 635 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
| 636 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 637 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 638 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 639 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 640 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 641 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 642 | $($(target)_$(source)_DEFS)\
|
---|
[221] | 643 | $($(target)_$(source)_DEFS.$(bld_type))\
|
---|
| 644 | $($(target)_$(source)_DEFS.$(bld_trg))\
|
---|
| 645 | $($(target)_$(source)_DEFS.$(bld_trg_arch))\
|
---|
| 646 | $($(target)_$(source)_DEFS.$(bld_trg_cpu))\
|
---|
[74] | 647 | $($(target)_$(source)_$(type)DEFS)\
|
---|
[221] | 648 | $($(target)_$(source)_$(type)DEFS.$(bld_type))\
|
---|
| 649 | $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
|
---|
| 650 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[353] | 651 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
|
---|
| 652 | incs :=\
|
---|
[221] | 653 | $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 654 | $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 655 | $($(target)_$(source)_$(type)INCS.$(bld_trg))\
|
---|
| 656 | $($(target)_$(source)_$(type)INCS.$(bld_type))\
|
---|
[73] | 657 | $($(target)_$(source)_$(type)INCS)\
|
---|
[221] | 658 | $($(target)_$(source)_INCS.$(bld_trg_cpu))\
|
---|
| 659 | $($(target)_$(source)_INCS.$(bld_trg_arch))\
|
---|
| 660 | $($(target)_$(source)_INCS.$(bld_trg))\
|
---|
| 661 | $($(target)_$(source)_INCS.$(bld_type))\
|
---|
[73] | 662 | $($(target)_$(source)_INCS)\
|
---|
[221] | 663 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
| 664 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
[133] | 665 | $($(target)_$(source)_SDKS),\
|
---|
[353] | 666 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 667 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 668 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 669 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 670 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 671 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
| 672 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 673 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 674 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 675 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 676 | $($(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 677 | $($(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 678 | $($(source)_$(type)INCS.$(bld_trg))\
|
---|
| 679 | $($(source)_$(type)INCS.$(bld_type))\
|
---|
[73] | 680 | $($(source)_$(type)INCS)\
|
---|
[221] | 681 | $($(source)_INCS.$(bld_trg_cpu))\
|
---|
| 682 | $($(source)_INCS.$(bld_trg_arch))\
|
---|
| 683 | $($(source)_INCS.$(bld_trg))\
|
---|
| 684 | $($(source)_INCS.$(bld_type))\
|
---|
[73] | 685 | $($(source)_INCS)\
|
---|
[221] | 686 | $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
|
---|
| 687 | $($(source)_SDKS.$(bld_type)) \
|
---|
[78] | 688 | $($(source)_SDKS),\
|
---|
[353] | 689 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 690 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 691 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 692 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 693 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 694 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
| 695 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 696 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 697 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 698 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 699 | $($(target)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 700 | $($(target)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 701 | $($(target)_$(type)INCS.$(bld_trg))\
|
---|
| 702 | $($(target)_$(type)INCS.$(bld_type))\
|
---|
[73] | 703 | $($(target)_$(type)INCS)\
|
---|
[221] | 704 | $($(target)_INCS.$(bld_trg_cpu))\
|
---|
| 705 | $($(target)_INCS.$(bld_trg_arch))\
|
---|
| 706 | $($(target)_INCS.$(bld_trg))\
|
---|
| 707 | $($(target)_INCS.$(bld_type))\
|
---|
[73] | 708 | $($(target)_INCS)\
|
---|
[221] | 709 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
| 710 | $($(target)_SDKS.$(bld_type)) \
|
---|
[78] | 711 | $($(target)_SDKS),\
|
---|
[353] | 712 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 713 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 714 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 715 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 716 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 717 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
| 718 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 719 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 720 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 721 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 722 | $(INCS.$(bld_trg_cpu))\
|
---|
| 723 | $(INCS.$(bld_trg_arch))\
|
---|
| 724 | $(INCS.$(bld_trg))\
|
---|
| 725 | $(INCS.$(bld_type))\
|
---|
[73] | 726 | $(INCS)\
|
---|
[221] | 727 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
| 728 | $(SDKS.$(bld_type)) \
|
---|
[78] | 729 | $(SDKS),\
|
---|
[353] | 730 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 731 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 732 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 733 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 734 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 735 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
| 736 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 737 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 738 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 739 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 740 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 741 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 742 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
|
---|
| 743 | $(TOOL_$(tool)_$(type)INCS.$(bld_type))\
|
---|
[353] | 744 | $(TOOL_$(tool)_$(type)INCS)
|
---|
| 745 | flags :=\
|
---|
[73] | 746 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
[221] | 747 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
|
---|
| 748 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
|
---|
| 749 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
| 750 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 751 | $($(type)FLAGS)\
|
---|
[221] | 752 | $($(type)FLAGS.$(bld_type))\
|
---|
| 753 | $($(type)FLAGS.$(bld_trg))\
|
---|
| 754 | $($(type)FLAGS.$(bld_trg_arch))\
|
---|
| 755 | $($(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 756 | $($(target)_$(type)FLAGS)\
|
---|
[221] | 757 | $($(target)_$(type)FLAGS.$(bld_type))\
|
---|
| 758 | $($(target)_$(type)FLAGS.$(bld_trg))\
|
---|
| 759 | $($(target)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
| 760 | $($(target)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 761 | $($(source)_$(type)FLAGS)\
|
---|
[221] | 762 | $($(source)_$(type)FLAGS.$(bld_type))\
|
---|
| 763 | $($(source)_$(type)FLAGS.$(bld_trg))\
|
---|
| 764 | $($(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
| 765 | $($(source)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 766 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
[221] | 767 | $($(target)_$(source)_$(type)FLAGS.$(bld_type))\
|
---|
| 768 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
|
---|
| 769 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
[353] | 770 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
|
---|
| 771 | objsuff := $(firstword \
|
---|
[221] | 772 | $($(target)_$(source)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 773 | $($(target)_$(source)_OBJSUFF)\
|
---|
[221] | 774 | $($(source)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 775 | $($(source)_OBJSUFF)\
|
---|
[221] | 776 | $($(target)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 777 | $($(target)_OBJSUFF)\
|
---|
[221] | 778 | $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
|
---|
[74] | 779 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
[353] | 780 | $(SUFF_OBJ))
|
---|
| 781 | obj := $(outbase)$(objsuff)
|
---|
| 782 | deps := \
|
---|
[184] | 783 | $($(target)_$(source)_DEPS)\
|
---|
[353] | 784 | $($(target)_$(source)_DEPS.$(bld_type))\
|
---|
| 785 | $($(target)_$(source)_DEPS.$(bld_trg))\
|
---|
| 786 | $($(target)_$(source)_DEPS.$(bld_trg_arch))\
|
---|
| 787 | $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
|
---|
[184] | 788 | $($(source)_DEPS)\
|
---|
[221] | 789 | $($(source)_DEPS.$(bld_type))\
|
---|
| 790 | $($(source)_DEPS.$(bld_trg))\
|
---|
[353] | 791 | $($(source)_DEPS.$(bld_trg_arch))\
|
---|
| 792 | $($(source)_DEPS.$(bld_trg_cpu))\
|
---|
[184] | 793 | $($(target)_DEPS)\
|
---|
[353] | 794 | $($(target)_DEPS.$(bld_type))\
|
---|
[221] | 795 | $($(target)_DEPS.$(bld_trg_arch))\
|
---|
[353] | 796 | $($(target)_DEPS.$(bld_trg_cpu))
|
---|
[73] | 797 |
|
---|
[380] | 798 | # dependencies
|
---|
| 799 | dep := $(obj)$(SUFF_DEP)
|
---|
| 800 | ifndef NO_COMPILE_DEPS
|
---|
| 801 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 802 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 803 | endif
|
---|
[184] | 804 |
|
---|
| 805 | #$ (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] | 806 | ifndef TOOL_$(tool)_COMPILE_$(type)_CMDS
|
---|
[353] | 807 | $(warning kBuild: tools: \
|
---|
[221] | 808 | 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 809 | 2 $($(target)_$(source)_$(type)TOOL) \
|
---|
[221] | 810 | 3 $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
[106] | 811 | 4 $($(target)_$(source)_TOOL) \
|
---|
[221] | 812 | 5 $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 813 | 6 $($(target)_$(type)TOOL) \
|
---|
[221] | 814 | 7 $($(target)_TOOL.$(bld_trg)) \
|
---|
[106] | 815 | 8 $($(target)_TOOL) \
|
---|
[221] | 816 | 9 $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 817 | 10 $($(source)_$(type)TOOL) \
|
---|
[221] | 818 | 11 $($(source)_TOOL.$(bld_trg)) \
|
---|
[106] | 819 | 12 $($(source)_TOOL) \
|
---|
[221] | 820 | 13 $($(type)TOOL.$(bld_trg)) \
|
---|
[106] | 821 | 14 $($(type)TOOL) \
|
---|
[221] | 822 | 15 $(TOOL.$(bld_trg)) \
|
---|
[106] | 823 | 16 $(TOOL) )
|
---|
[380] | 824 | $(error kBuild: TOOL_$(tool)_COMPILE_$(type)_CMDS is not defined. source=$(source) target=$(target) )
|
---|
[97] | 825 | endif
|
---|
[353] | 826 |
|
---|
[380] | 827 | # call the tool
|
---|
| 828 | $(target)_$(source)_CMDS_ := $(TOOL_$(tool)_COMPILE_$(type)_CMDS)
|
---|
| 829 | $(target)_$(source)_OUTPUT_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT)
|
---|
| 830 | $(target)_$(source)_DEPEND_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPEND) $(deps) $(source)
|
---|
| 831 | $(target)_$(source)_DEPORD_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPORD) $(dirdep)
|
---|
[73] | 832 |
|
---|
[380] | 833 | # generate the compile rule.
|
---|
| 834 | $(eval $(def_target_source_rule))
|
---|
[205] | 835 |
|
---|
[380] | 836 | _OUT_FILES += $($(target)_$(source)_OUTPUT_)
|
---|
[353] | 837 | $(target)_OBJS_ += $(obj)
|
---|
[73] | 838 |
|
---|
| 839 | endef
|
---|
| 840 |
|
---|
| 841 | ## Generic macro for processing all target sources.
|
---|
[74] | 842 | # @param $(target) Normalized target name.
|
---|
[73] | 843 | define def_target_sources
|
---|
| 844 | #$ (warning def_target_sources)
|
---|
| 845 | # C sources
|
---|
[353] | 846 | type := C
|
---|
| 847 | $(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
| 848 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
[73] | 849 |
|
---|
| 850 | # C++ sources
|
---|
[353] | 851 | type := CXX
|
---|
| 852 | $(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
| 853 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
[73] | 854 |
|
---|
| 855 | # ASM sources
|
---|
[353] | 856 | type := AS
|
---|
| 857 | $(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
| 858 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
| 859 |
|
---|
[73] | 860 | endef
|
---|
| 861 |
|
---|
| 862 |
|
---|
[219] | 863 |
|
---|
[353] | 864 | ## Generic macro for generating the install rule(s) for a target
|
---|
| 865 | # and update the globals with default out.
|
---|
[219] | 866 | #
|
---|
[353] | 867 | # @param $(target) Normalized target name.
|
---|
| 868 | # @param $(out) The output file.
|
---|
| 869 | # @param $(definst) The default _INST value.
|
---|
| 870 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
| 871 | # @obsolete
|
---|
| 872 | define def_target_install_pluss
|
---|
| 873 | ifndef $(target)_NOINST
|
---|
| 874 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 875 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
[219] | 876 |
|
---|
[353] | 877 | $(eval $(def_link_install_rule))
|
---|
[239] | 878 |
|
---|
[353] | 879 | _INSTALLS += $(INSTARGET_$(target))
|
---|
[272] | 880 |
|
---|
[353] | 881 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
| 882 | $(typevar) += $(INSTARGET_$(target))
|
---|
[219] | 883 | else
|
---|
[353] | 884 | $(typevar) += $(out)
|
---|
[219] | 885 | endif
|
---|
[353] | 886 | else # _NOINST
|
---|
| 887 | $(typevar) += $(out)
|
---|
| 888 | endif
|
---|
| 889 |
|
---|
| 890 | _OUT_FILES += $(out)
|
---|
| 891 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
| 892 | _OBJS += $($(target)_OBJS_)
|
---|
| 893 |
|
---|
[219] | 894 | endef
|
---|
| 895 |
|
---|
| 896 |
|
---|
| 897 |
|
---|
| 898 | #
|
---|
[72] | 899 | # LIBRARIES
|
---|
[73] | 900 | #
|
---|
[72] | 901 |
|
---|
| 902 | ## Library (one).
|
---|
[74] | 903 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 904 | define def_lib
|
---|
[145] | 905 | # library basics
|
---|
[222] | 906 | ## @todo prefix
|
---|
[353] | 907 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 908 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 909 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 910 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 911 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
[78] | 912 | ifeq ($(tool),)
|
---|
[353] | 913 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
[78] | 914 | endif
|
---|
[353] | 915 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 916 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 917 | suff := $(firstword\
|
---|
[221] | 918 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
[126] | 919 | $($(target)_LIBSUFF)\
|
---|
[221] | 920 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
[126] | 921 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
[353] | 922 | $(SUFF_LIB))
|
---|
| 923 | out := $(outbase)$(suff)
|
---|
| 924 | TARGET_$(target) := $(out)
|
---|
| 925 | $(target)_OBJS_ := $(filter %.o %.obj, \
|
---|
| 926 | $($(target)_SOURCES) \
|
---|
| 927 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 928 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 929 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 930 | $($(target)_SOURCES.$(bld_type)))
|
---|
[145] | 931 |
|
---|
[353] | 932 |
|
---|
[145] | 933 | # source -> object
|
---|
[353] | 934 | $(eval $(value def_target_sources))
|
---|
[145] | 935 |
|
---|
| 936 | # library linking
|
---|
[353] | 937 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
| 938 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 939 | flags :=\
|
---|
[74] | 940 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
[221] | 941 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
[74] | 942 | $(ARFLAGS)\
|
---|
[221] | 943 | $(ARFLAGS.$(bld_type))\
|
---|
[74] | 944 | $($(target)_ARFLAGS)\
|
---|
[353] | 945 | $($(target)_ARFLAGS.$(bld_type))
|
---|
| 946 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
| 947 | $($(target)_SOURCES) \
|
---|
| 948 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 949 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 950 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 951 | $($(target)_SOURCES.$(bld_type)))
|
---|
| 952 | objs = $($(target)_OBJS_)
|
---|
| 953 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
[78] | 954 | ## @todo fix dependencies on makefiles an such
|
---|
[353] | 955 | deps := $($(target)_DEPS)
|
---|
[72] | 956 |
|
---|
[380] | 957 | # dependency file
|
---|
| 958 | dep := $(out)$(SUFF_DEP)
|
---|
| 959 | ifndef NO_LINK_CMDS_DEP
|
---|
| 960 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 961 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 962 | endif
|
---|
[72] | 963 |
|
---|
[380] | 964 | # check that the tool is defined.
|
---|
| 965 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
| 966 | $(warning kBuild: tools: \
|
---|
| 967 | 1 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 968 | 2 $($(target)_$(source)TOOL) \
|
---|
| 969 | 3 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 970 | 4 $($(target)_TOOL) \
|
---|
| 971 | 5 $($(source)TOOL) \
|
---|
| 972 | 6 $($(source)TOOL.$(bld_trg)) \
|
---|
| 973 | 7 $(TOOL.$(bld_trg)) \
|
---|
| 974 | 8 $(TOOL) )
|
---|
| 975 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
| 976 | endif
|
---|
| 977 |
|
---|
| 978 | # call the tool
|
---|
| 979 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
| 980 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
| 981 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $(objs)
|
---|
| 982 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep)
|
---|
| 983 |
|
---|
[412] | 984 | # generate the link rule.
|
---|
[380] | 985 | $(eval $(def_link_rule))
|
---|
| 986 |
|
---|
[353] | 987 | # installing and globals
|
---|
| 988 | definst := $(PATH_LIB)
|
---|
[380] | 989 | typevar := _LIBS
|
---|
[353] | 990 | $(eval $(value def_target_install_pluss))
|
---|
[72] | 991 | endef
|
---|
| 992 |
|
---|
| 993 | # Process libraries
|
---|
[380] | 994 | mode := 0644
|
---|
[353] | 995 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(value def_lib)))
|
---|
[72] | 996 |
|
---|
| 997 |
|
---|
| 998 | #
|
---|
[353] | 999 | # Link operations.
|
---|
[72] | 1000 | #
|
---|
| 1001 |
|
---|
[353] | 1002 | ##
|
---|
| 1003 | # Link prolog
|
---|
| 1004 | #
|
---|
| 1005 | # @param $(target) Normalized target name.
|
---|
| 1006 | # @param $(EXT) EXE,DLL,SYS.
|
---|
| 1007 | # @param $(definst) The default _INST value.
|
---|
| 1008 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
[380] | 1009 | define def_link_common
|
---|
[353] | 1010 | # basics
|
---|
| 1011 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1012 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
| 1013 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
| 1014 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
[145] | 1015 |
|
---|
[353] | 1016 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
| 1017 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 1018 | suff := $(firstword \
|
---|
| 1019 | $($(target)_$(EXT)SUFF) \
|
---|
| 1020 | $($(target)_$(EXT)SUFF) \
|
---|
| 1021 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
| 1022 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
| 1023 | out := $(outbase)$(suff)
|
---|
| 1024 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 1025 | TARGET_$(target) := $(out)
|
---|
| 1026 | $(target)_OBJS_ := $(filter %.o %.obj, \
|
---|
| 1027 | $($(target)_SOURCES) \
|
---|
| 1028 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1029 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 1030 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1031 | $($(target)_SOURCES.$(bld_type)))
|
---|
| 1032 |
|
---|
[145] | 1033 | # source -> object
|
---|
[353] | 1034 | $(eval $(value def_target_sources))
|
---|
[145] | 1035 |
|
---|
[353] | 1036 | # more library stuff.
|
---|
| 1037 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
| 1038 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 1039 | flags :=\
|
---|
[74] | 1040 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
[221] | 1041 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
| 1042 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
| 1043 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
| 1044 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
[74] | 1045 | $(LDFLAGS)\
|
---|
[221] | 1046 | $(LDFLAGS.$(bld_type))\
|
---|
| 1047 | $(LDFLAGS.$(bld_trg))\
|
---|
| 1048 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
| 1049 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
[74] | 1050 | $($(target)_LDFLAGS)\
|
---|
[221] | 1051 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
| 1052 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
| 1053 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
[353] | 1054 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
| 1055 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
| 1056 | $($(target)_SOURCES)\
|
---|
| 1057 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1058 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 1059 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1060 | $($(target)_SOURCES.$(bld_type)))
|
---|
| 1061 | objs = $($(target)_OBJS_)
|
---|
| 1062 | libs :=\
|
---|
[221] | 1063 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
| 1064 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
| 1065 | $($(target)_LIBS.$(bld_trg))\
|
---|
| 1066 | $($(target)_LIBS.$(bld_type))\
|
---|
[74] | 1067 | $($(target)_LIBS)\
|
---|
[221] | 1068 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1069 | $($(target)_SDKS.$(bld_type)) \
|
---|
[122] | 1070 | $($(target)_SDKS),\
|
---|
[353] | 1071 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
| 1072 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 1073 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 1074 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 1075 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 1076 | $(LIBS.$(bld_trg_cpu))\
|
---|
| 1077 | $(LIBS.$(bld_trg_arch))\
|
---|
| 1078 | $(LIBS.$(bld_trg))\
|
---|
| 1079 | $(LIBS.$(bld_type))\
|
---|
[74] | 1080 | $(LIBS)\
|
---|
[221] | 1081 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
| 1082 | $(SDKS.$(bld_type)) \
|
---|
[122] | 1083 | $(SDKS),\
|
---|
[353] | 1084 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
| 1085 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 1086 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 1087 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 1088 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 1089 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
| 1090 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
| 1091 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
| 1092 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
[353] | 1093 | $(TOOL_$(tool)_LIBS)
|
---|
| 1094 | libpath :=\
|
---|
[221] | 1095 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
| 1096 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1097 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
| 1098 | $($(target)_LIBPATH.$(bld_type))\
|
---|
[74] | 1099 | $($(target)_LIBPATH)\
|
---|
[221] | 1100 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1101 | $($(target)_SDKS.$(bld_type)) \
|
---|
[122] | 1102 | $($(target)_SDKS),\
|
---|
[353] | 1103 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
| 1104 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1105 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 1106 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 1107 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 1108 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
| 1109 | $(LIBPATH.$(bld_trg_arch))\
|
---|
| 1110 | $(LIBPATH.$(bld_trg))\
|
---|
| 1111 | $(LIBPATH.$(bld_type))\
|
---|
[74] | 1112 | $(LIBPATH)\
|
---|
[221] | 1113 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
| 1114 | $(SDKS.$(bld_type)) \
|
---|
[122] | 1115 | $(SDKS),\
|
---|
[353] | 1116 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
| 1117 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1118 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 1119 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 1120 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 1121 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
| 1122 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1123 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
| 1124 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
[353] | 1125 | $(TOOL_$(tool)_LIBPATH)
|
---|
| 1126 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
[74] | 1127 | ## @todo fix dependencies
|
---|
[353] | 1128 | deps := $($(target)_DEPS)
|
---|
| 1129 |
|
---|
| 1130 | ## @todo this stuff can't be working.
|
---|
| 1131 | custom_pre := $(strip $(firstword \
|
---|
[221] | 1132 | $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
| 1133 | $($(target)_CUSTOM_PRE.$(bld_trg))\
|
---|
| 1134 | $($(target)_CUSTOM_PRE.$(bld_type))\
|
---|
[74] | 1135 | $($(target)_CUSTOM_PRE)\
|
---|
[221] | 1136 | $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
| 1137 | $(CUSTOM_PRE.$(bld_trg))\
|
---|
| 1138 | $(CUSTOM_PRE.$(bld_type))\
|
---|
[74] | 1139 | $(CUSTOM_PRE)\
|
---|
[353] | 1140 | ))
|
---|
| 1141 | custom_post := $(strip $(firstword \
|
---|
[221] | 1142 | $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
| 1143 | $($(target)_CUSTOM_POST.$(bld_trg))\
|
---|
| 1144 | $($(target)_CUSTOM_POST.$(bld_type))\
|
---|
[74] | 1145 | $($(target)_CUSTOM_POST)\
|
---|
[221] | 1146 | $(CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
| 1147 | $(CUSTOM_POST.$(bld_trg))\
|
---|
| 1148 | $(CUSTOM_POST.$(bld_type))\
|
---|
[74] | 1149 | $(CUSTOM_POST)\
|
---|
[353] | 1150 | ))
|
---|
[72] | 1151 |
|
---|
[353] | 1152 | # installation targets
|
---|
| 1153 | ifndef $(target)_NOINST
|
---|
| 1154 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 1155 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
| 1156 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
| 1157 | $(typevar) += $(INSTARGET_$(target))
|
---|
| 1158 | else
|
---|
| 1159 | $(typevar) += $(out)
|
---|
| 1160 | endif
|
---|
| 1161 | # generate the install rule
|
---|
| 1162 | $(eval $(def_link_install_rule))
|
---|
| 1163 |
|
---|
| 1164 | else # NOINST
|
---|
| 1165 | INSTARGET_$(target) :=
|
---|
| 1166 | $(typevar) += $(out)
|
---|
| 1167 | endif # NOINST
|
---|
| 1168 |
|
---|
[380] | 1169 | # dependency file
|
---|
| 1170 | dep := $(outbase)$(SUFF_DEP)
|
---|
| 1171 | ifndef NO_LINK_CMDS_DEP
|
---|
| 1172 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 1173 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 1174 | endif
|
---|
[353] | 1175 |
|
---|
[380] | 1176 | # check that the tool is defined.
|
---|
| 1177 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
| 1178 | $(warning kBuild: tools: \
|
---|
| 1179 | 1 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 1180 | 2 $($(target)_$(source)TOOL) \
|
---|
| 1181 | 3 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 1182 | 4 $($(target)_TOOL) \
|
---|
| 1183 | 5 $($(source)TOOL) \
|
---|
| 1184 | 6 $($(source)TOOL.$(bld_trg)) \
|
---|
| 1185 | 7 $(TOOL.$(bld_trg)) \
|
---|
| 1186 | 8 $(TOOL) )
|
---|
| 1187 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
| 1188 | endif
|
---|
[353] | 1189 |
|
---|
[380] | 1190 | # call the tool
|
---|
| 1191 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
| 1192 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
| 1193 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $(objs)
|
---|
| 1194 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep)
|
---|
[353] | 1195 |
|
---|
[412] | 1196 | # generate the link rule.
|
---|
[380] | 1197 | $(eval $(def_link_rule))
|
---|
| 1198 |
|
---|
[412] | 1199 |
|
---|
[380] | 1200 | # Update globals.
|
---|
[353] | 1201 | _OBJS += $($(target)_OBJS_)
|
---|
[380] | 1202 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
[353] | 1203 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
[380] | 1204 | _INSTALLS += $(INSTARGET_$(target))
|
---|
[353] | 1205 |
|
---|
| 1206 | endef
|
---|
| 1207 |
|
---|
| 1208 |
|
---|
| 1209 | #
|
---|
| 1210 | # BLDPROGS
|
---|
| 1211 | #
|
---|
| 1212 |
|
---|
| 1213 | ## Build program (one).
|
---|
| 1214 | # @param $(target) Normalized target (program) name.
|
---|
| 1215 | define def_bldprog
|
---|
| 1216 |
|
---|
| 1217 | # set NOINST if not forced installation.
|
---|
| 1218 | ifndef $(target)_INST
|
---|
| 1219 | $(target)_NOINST := 1
|
---|
| 1220 | endif
|
---|
| 1221 |
|
---|
[380] | 1222 | # do the usual stuff.
|
---|
| 1223 | $(eval $(value def_link_common))
|
---|
[353] | 1224 |
|
---|
| 1225 | endef
|
---|
| 1226 |
|
---|
| 1227 | # Process build programs.
|
---|
| 1228 | EXT := EXE
|
---|
| 1229 | EXTPRE := HOST
|
---|
[380] | 1230 | tool_do := LINK_PROGRAM
|
---|
[353] | 1231 | definst := $(PATH_BIN)
|
---|
| 1232 | typevar := _BLDPROGS
|
---|
[380] | 1233 | mode := 0755
|
---|
[353] | 1234 | bld_trg_base_var := PLATFORM
|
---|
| 1235 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(value def_bldprog)))
|
---|
| 1236 |
|
---|
| 1237 |
|
---|
| 1238 |
|
---|
| 1239 | #
|
---|
| 1240 | # DLLS
|
---|
| 1241 | #
|
---|
| 1242 |
|
---|
[189] | 1243 | # Process dlls
|
---|
[353] | 1244 | EXT := DLL
|
---|
| 1245 | EXTPRE :=
|
---|
[380] | 1246 | tool_do := LINK_DLL
|
---|
[353] | 1247 | definst := $(PATH_DLL)
|
---|
| 1248 | typevar := _DLLS
|
---|
[380] | 1249 | mode := 0755
|
---|
[353] | 1250 | bld_trg_base_var := TARGET
|
---|
[380] | 1251 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
[74] | 1252 |
|
---|
| 1253 |
|
---|
[72] | 1254 | #
|
---|
[189] | 1255 | # Process import libraries.
|
---|
[72] | 1256 | #
|
---|
[219] | 1257 | # - On OS/2 and windows these are libraries.
|
---|
[189] | 1258 | # - On other platforms they are fake DLLs.
|
---|
[438] | 1259 | ifeq ($(filter-out win64 win32 os2,$(BUILD_TARGET)),)
|
---|
[353] | 1260 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_lib)))
|
---|
[189] | 1261 | else
|
---|
[380] | 1262 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
[189] | 1263 | endif
|
---|
[353] | 1264 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), \
|
---|
| 1265 | $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
|
---|
[72] | 1266 |
|
---|
[189] | 1267 |
|
---|
| 1268 | #
|
---|
| 1269 | # PROGRAMS
|
---|
| 1270 | #
|
---|
| 1271 |
|
---|
[353] | 1272 | # Process programs
|
---|
| 1273 | EXT := EXE
|
---|
| 1274 | EXTPRE :=
|
---|
[380] | 1275 | tool_do := LINK_PROGRAM
|
---|
[353] | 1276 | definst := $(PATH_BIN)
|
---|
| 1277 | typevar := _PROGRAMS
|
---|
[380] | 1278 | mode := 0755
|
---|
[353] | 1279 | bld_trg_base_var := TARGET
|
---|
[380] | 1280 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
[130] | 1281 |
|
---|
| 1282 |
|
---|
[189] | 1283 |
|
---|
[72] | 1284 | #
|
---|
[83] | 1285 | # SYSMODS
|
---|
[72] | 1286 | #
|
---|
| 1287 |
|
---|
[130] | 1288 | # Process sysmods
|
---|
[353] | 1289 | EXT := SYS
|
---|
| 1290 | EXTPRE :=
|
---|
[380] | 1291 | tool_do := LINK_SYSMOD
|
---|
[353] | 1292 | definst := $(PATH_SYS)
|
---|
| 1293 | typevar := _SYSMODS
|
---|
[380] | 1294 | mode := 0644
|
---|
[353] | 1295 | bld_trg_base_var := TARGET
|
---|
[380] | 1296 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
[83] | 1297 |
|
---|
| 1298 |
|
---|
[72] | 1299 | #
|
---|
| 1300 | # OTHERS
|
---|
| 1301 | #
|
---|
[190] | 1302 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
[72] | 1303 |
|
---|
| 1304 |
|
---|
[353] | 1305 | #
|
---|
| 1306 | # INSTALLS
|
---|
| 1307 | #
|
---|
[72] | 1308 |
|
---|
[353] | 1309 | ## generate the install rule
|
---|
| 1310 | define def_install_src_rule
|
---|
| 1311 | # the install rule
|
---|
| 1312 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
[380] | 1313 | $$(if $$(filter $(INSTALL),$(inscmd)),,$$(RM) -f $$@)
|
---|
[353] | 1314 | $(inscmd)
|
---|
| 1315 | endef
|
---|
| 1316 |
|
---|
| 1317 | ## install one file
|
---|
| 1318 | define def_install_src
|
---|
| 1319 |
|
---|
| 1320 | # deal with '=>' in the source file name.
|
---|
| 1321 | srcdst := $(subst =>, ,$(src))
|
---|
| 1322 | srcsrc := $(firstword $(srcdst))
|
---|
[424] | 1323 | srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
[353] | 1324 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
| 1325 |
|
---|
| 1326 | # _INSTFUN
|
---|
| 1327 | ifdef $(srcsrc)_INSTFUN
|
---|
| 1328 | instfun := $(srcsrc)_INSTFUN
|
---|
| 1329 | else
|
---|
| 1330 | ifdef $(target)_INSTFUN
|
---|
| 1331 | instfun := $(target)_INSTFUN
|
---|
| 1332 | else
|
---|
| 1333 | instfun := _INSTALL_FILE
|
---|
| 1334 | endif
|
---|
| 1335 | endif
|
---|
| 1336 |
|
---|
| 1337 | # _INST
|
---|
| 1338 | ifdef $(srcsrc)_INST
|
---|
[424] | 1339 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
---|
[353] | 1340 | else
|
---|
| 1341 | ifdef $(target)_INST
|
---|
[424] | 1342 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
---|
[353] | 1343 | else
|
---|
[424] | 1344 | inst := $(dir $(srcdstdir))
|
---|
[353] | 1345 | endif
|
---|
| 1346 | endif
|
---|
| 1347 |
|
---|
| 1348 | # calc target
|
---|
[380] | 1349 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
[424] | 1350 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
---|
[353] | 1351 |
|
---|
[414] | 1352 | # mode, uid and gid
|
---|
| 1353 | mode := $(firstword \
|
---|
| 1354 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 1355 | $($(target)_$(srcsrc)_MODE) \
|
---|
| 1356 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
| 1357 | $($(target)_$(srcdst)_MODE) \
|
---|
| 1358 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 1359 | $($(srcsrc)_MODE) \
|
---|
| 1360 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
| 1361 | $($(srcdst)_MODE) \
|
---|
| 1362 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 1363 | $($(target)_MODE))
|
---|
| 1364 | uid := $(firstword \
|
---|
| 1365 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
| 1366 | $($(target)_$(srcsrc)_UID) \
|
---|
| 1367 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
| 1368 | $($(target)_$(srcdst)_UID) \
|
---|
| 1369 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
| 1370 | $($(srcsrc)_UID) \
|
---|
| 1371 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
| 1372 | $($(srcdst)_UID) \
|
---|
| 1373 | $($(target)_UID.$(bld_trg)) \
|
---|
| 1374 | $($(target)_UID))
|
---|
| 1375 | gid := $(firstword \
|
---|
| 1376 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
| 1377 | $($(target)_$(srcsrc)_GID) \
|
---|
| 1378 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
| 1379 | $($(target)_$(srcdst)_GID) \
|
---|
| 1380 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
| 1381 | $($(srcsrc)_GID) \
|
---|
| 1382 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
| 1383 | $($(srcdst)_GID) \
|
---|
| 1384 | $($(target)_GID.$(bld_trg)) \
|
---|
| 1385 | $($(target)_GID))
|
---|
| 1386 |
|
---|
[353] | 1387 | # create the command
|
---|
| 1388 | ifdef $(srcsrc)_INSTALLER
|
---|
| 1389 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
| 1390 | else
|
---|
| 1391 | ifdef $(target)_INSTALLER
|
---|
| 1392 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
| 1393 | else
|
---|
[414] | 1394 | inscmd := $$(INSTALL)\
|
---|
| 1395 | $(if $(uid),-o $(uid))\
|
---|
| 1396 | $(if $(gid),-g $(gid))\
|
---|
| 1397 | $(if $(mode),-m $(mode))\
|
---|
| 1398 | $(srcsrc) $(insdst)
|
---|
[353] | 1399 | endif
|
---|
| 1400 | endif
|
---|
| 1401 |
|
---|
| 1402 | # generate the rule (need double evaluation here)
|
---|
| 1403 | $(eval $(def_install_src_rule))
|
---|
| 1404 |
|
---|
| 1405 | INSTARGET_$(target) += $(insdst)
|
---|
| 1406 | endef
|
---|
| 1407 |
|
---|
| 1408 |
|
---|
| 1409 | ## generate the symlink rule
|
---|
| 1410 | define def_install_symlink_rule
|
---|
| 1411 | # the install rule
|
---|
| 1412 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
| 1413 | $$(RM) -f $$@
|
---|
[380] | 1414 | $$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
[353] | 1415 | endef
|
---|
| 1416 |
|
---|
| 1417 | ## create one symlink
|
---|
| 1418 | define def_install_symlink
|
---|
| 1419 |
|
---|
| 1420 | # deal with '=>' in the source file name.
|
---|
[380] | 1421 | symdst := $(subst =>, ,$(src))
|
---|
| 1422 | symlnk := $(firstword $(symdst))
|
---|
| 1423 | symdst := $(word $(words $(symdst)),$(symdst))
|
---|
[353] | 1424 |
|
---|
| 1425 | # _INSTFUN
|
---|
[380] | 1426 | ifdef $(symlnk)_INSTFUN
|
---|
| 1427 | instfun := $(symlnk)_INSTFUN
|
---|
[353] | 1428 | else
|
---|
| 1429 | ifdef $(target)_INSTFUN
|
---|
| 1430 | instfun := $(target)_INSTFUN
|
---|
| 1431 | else
|
---|
| 1432 | instfun := _INSTALL_FILE
|
---|
| 1433 | endif
|
---|
| 1434 | endif
|
---|
| 1435 |
|
---|
| 1436 | # _INST
|
---|
[380] | 1437 | ifdef $(symlnk)_INST
|
---|
| 1438 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
[353] | 1439 | else
|
---|
| 1440 | ifdef $(target)_INST
|
---|
[380] | 1441 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
[353] | 1442 | else
|
---|
[380] | 1443 | inst := $(dir $(symlnk))
|
---|
[353] | 1444 | endif
|
---|
| 1445 | endif
|
---|
| 1446 |
|
---|
| 1447 | # calc target
|
---|
[380] | 1448 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
| 1449 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
[353] | 1450 |
|
---|
| 1451 | # generate the rule (need double evaluation here)
|
---|
| 1452 | $(eval $(def_install_symlink_rule))
|
---|
| 1453 |
|
---|
| 1454 | INSTARGET_$(target) += $(insdst)
|
---|
| 1455 | endef
|
---|
| 1456 |
|
---|
[412] | 1457 |
|
---|
[380] | 1458 | ## generate the install rule
|
---|
| 1459 | define def_install_directory_rule
|
---|
| 1460 | # the install rule
|
---|
| 1461 | $(insdst):
|
---|
| 1462 | $(INSTALL) -d \
|
---|
| 1463 | $(if $(uid),-o $(uid))\
|
---|
| 1464 | $(if $(gid),-g $(gid))\
|
---|
| 1465 | $(if $(mode),-m $(mode))\
|
---|
| 1466 | $(insdst)
|
---|
[412] | 1467 |
|
---|
| 1468 | .NOTPARALLEL: $(insdst)
|
---|
[380] | 1469 | endef
|
---|
| 1470 |
|
---|
[412] | 1471 |
|
---|
[380] | 1472 | ## create one directory
|
---|
| 1473 | define def_install_directory
|
---|
| 1474 |
|
---|
| 1475 | # _INST
|
---|
| 1476 | ifdef $(directory)_INST
|
---|
| 1477 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
| 1478 | else
|
---|
| 1479 | ifdef $(target)_INST
|
---|
| 1480 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
| 1481 | else
|
---|
| 1482 | inst := $(PATH_INS)
|
---|
| 1483 | endif
|
---|
| 1484 | endif
|
---|
| 1485 |
|
---|
| 1486 | mode := $(firstword \
|
---|
| 1487 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
| 1488 | $($(target)_$(directory)_MODE) \
|
---|
| 1489 | $($(directory)_MODE.$(bld_trg)) \
|
---|
| 1490 | $($(directory)_MODE) \
|
---|
| 1491 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 1492 | $($(target)_MODE))
|
---|
| 1493 | uid := $(firstword \
|
---|
| 1494 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
| 1495 | $($(target)_$(directory)_UID) \
|
---|
| 1496 | $($(directory)_UID.$(bld_trg)) \
|
---|
| 1497 | $($(directory)_UID) \
|
---|
| 1498 | $($(target)_UID.$(bld_trg)) \
|
---|
| 1499 | $($(target)_UID))
|
---|
| 1500 | gid := $(firstword \
|
---|
| 1501 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
| 1502 | $($(target)_$(directory)_GID) \
|
---|
| 1503 | $($(directory)_GID.$(bld_trg)) \
|
---|
| 1504 | $($(directory)_GID) \
|
---|
| 1505 | $($(target)_GID.$(bld_trg)) \
|
---|
| 1506 | $($(target)_GID))
|
---|
| 1507 |
|
---|
| 1508 | insdst := $(inst)/$(directory)/
|
---|
| 1509 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
| 1510 |
|
---|
| 1511 | # generate the rule (need double evaluation here)
|
---|
| 1512 | $(eval $(def_install_directory_rule))
|
---|
| 1513 |
|
---|
| 1514 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
| 1515 | endef
|
---|
| 1516 |
|
---|
| 1517 |
|
---|
[353] | 1518 | ## process one install target.
|
---|
| 1519 | define def_install
|
---|
| 1520 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1521 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 1522 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 1523 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 1524 |
|
---|
| 1525 | INSTARGET_$(target) :=
|
---|
[380] | 1526 | INSTARGET_DIRS_$(target) :=
|
---|
| 1527 |
|
---|
| 1528 | $(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \
|
---|
| 1529 | $(eval $(value def_install_directory)))
|
---|
| 1530 |
|
---|
[353] | 1531 | $(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
|
---|
| 1532 | $(eval $(value def_install_src)))
|
---|
| 1533 |
|
---|
| 1534 | $(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
|
---|
| 1535 | $(eval $(value def_install_symlink)))
|
---|
| 1536 |
|
---|
[380] | 1537 | _INSTALLS += $(INSTARGET_$(target)) $($(target)_GOALS)
|
---|
| 1538 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
[353] | 1539 | endef
|
---|
| 1540 |
|
---|
| 1541 | ## process all install targets
|
---|
| 1542 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)), \
|
---|
| 1543 | $(eval $(value def_install)))
|
---|
| 1544 |
|
---|
| 1545 |
|
---|
[72] | 1546 | #
|
---|
[417] | 1547 | # PACKING
|
---|
| 1548 | #
|
---|
| 1549 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET))
|
---|
| 1550 |
|
---|
| 1551 |
|
---|
| 1552 | #
|
---|
[72] | 1553 | # DOCS
|
---|
| 1554 | #
|
---|
| 1555 |
|
---|
| 1556 |
|
---|
| 1557 | #
|
---|
[353] | 1558 | # DIRECTORIES
|
---|
| 1559 | #
|
---|
| 1560 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS)))
|
---|
[380] | 1561 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
[353] | 1562 |
|
---|
[380] | 1563 |
|
---|
[353] | 1564 | define def_mkdir_rule
|
---|
| 1565 | $(directory):
|
---|
| 1566 | $(call MSG_L1,Creating directory $$@)
|
---|
| 1567 | $(MKDIR) -p $$@
|
---|
[72] | 1568 | endef
|
---|
| 1569 |
|
---|
[353] | 1570 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
[72] | 1571 |
|
---|
[183] | 1572 |
|
---|
[72] | 1573 | #
|
---|
[353] | 1574 | # NOTHING
|
---|
[72] | 1575 | #
|
---|
[353] | 1576 | do-nothing:
|
---|
| 1577 | $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
[72] | 1578 |
|
---|
[183] | 1579 |
|
---|
[75] | 1580 | #
|
---|
[353] | 1581 | # CLEAN UP
|
---|
[75] | 1582 | #
|
---|
[353] | 1583 | do-clean:
|
---|
[380] | 1584 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
[72] | 1585 |
|
---|
[98] | 1586 |
|
---|
[353] | 1587 | #
|
---|
| 1588 | # PASSES (including directory and makefile walking)
|
---|
| 1589 | #
|
---|
[221] | 1590 |
|
---|
[75] | 1591 | ## Subdir
|
---|
| 1592 | # @param $(pass) Lowercase pass name.
|
---|
| 1593 | # @param $(PASS) Uppercase pass name.
|
---|
| 1594 | # @param $(subdir) Subdirectory
|
---|
| 1595 | # @param $(tag) tag to attach to the rule name.
|
---|
| 1596 | define def_pass_subdir
|
---|
[219] | 1597 | pass_$(pass)$(tag):: $(dep)
|
---|
| 1598 | + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
[75] | 1599 | endef
|
---|
[72] | 1600 |
|
---|
[75] | 1601 | ## Submakefile
|
---|
| 1602 | # @param $(pass) Lowercase pass name.
|
---|
| 1603 | # @param $(PASS) Uppercase pass name.
|
---|
| 1604 | # @param $(makefile) Makefile.
|
---|
| 1605 | # @param $(tag) tag to attach to the rule name.
|
---|
| 1606 | define def_pass_makefile
|
---|
[219] | 1607 | pass_$(pass)$(tag):: $(dep)
|
---|
| 1608 | + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
[75] | 1609 | endef
|
---|
[73] | 1610 |
|
---|
[75] | 1611 | ## Execute a pass.
|
---|
| 1612 | # @param $(pass) Lowercase pass name.
|
---|
| 1613 | # @param $(PASS) Uppercase pass name.
|
---|
[353] | 1614 | define def_pass_old
|
---|
[183] | 1615 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
| 1616 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
| 1617 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
| 1618 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
[75] | 1619 |
|
---|
| 1620 | $(eval tag:=_before)
|
---|
[219] | 1621 | $(eval dep:=)
|
---|
[183] | 1622 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1623 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
[75] | 1624 |
|
---|
| 1625 | $(eval tag:=_after)
|
---|
[219] | 1626 | $(eval dep:=pass_$(pass)_doit)
|
---|
[183] | 1627 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1628 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 1629 |
|
---|
| 1630 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 1631 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
[353] | 1632 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
[272] | 1633 | pass_$(pass)_this: pass_$(pass)_before
|
---|
[220] | 1634 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
| 1635 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
[219] | 1636 | pass_$(pass): pass_$(pass)_after
|
---|
[75] | 1637 |
|
---|
[183] | 1638 | endef
|
---|
| 1639 |
|
---|
[353] | 1640 | define def_pass
|
---|
| 1641 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
| 1642 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
| 1643 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
| 1644 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
[183] | 1645 |
|
---|
[353] | 1646 | $(eval tag:=_before)
|
---|
| 1647 | $(eval dep:=)
|
---|
| 1648 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1649 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
[75] | 1650 |
|
---|
[353] | 1651 | $(eval tag:=_after)
|
---|
| 1652 | $(eval dep:=pass_$(pass)_doit)
|
---|
| 1653 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1654 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 1655 |
|
---|
[380] | 1656 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 1657 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
| 1658 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
| 1659 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
| 1660 | pass_$(pass)_this: pass_$(pass)_before
|
---|
| 1661 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
| 1662 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
| 1663 | pass_$(pass): pass_$(pass)_after
|
---|
| 1664 | else
|
---|
[388] | 1665 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
[353] | 1666 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
| 1667 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
| 1668 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
| 1669 | pass_$(pass): \
|
---|
| 1670 | pass_$(pass)_before \
|
---|
| 1671 | pass_$(pass)_doit \
|
---|
[388] | 1672 | pass_$(pass)_after
|
---|
[353] | 1673 | endif
|
---|
[189] | 1674 |
|
---|
[353] | 1675 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
| 1676 | endef
|
---|
[75] | 1677 |
|
---|
[353] | 1678 | # Generate the defined passes.
|
---|
| 1679 | $(foreach PASS, $(PASSES), \
|
---|
| 1680 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 1681 | $(eval $(def_pass)))
|
---|
[75] | 1682 |
|
---|
[219] | 1683 | ## Pass order
|
---|
| 1684 | # @param $(pass) Current pass name.
|
---|
| 1685 | # @param $(prev_pass) The previous pass name.
|
---|
| 1686 | define def_pass_order
|
---|
[380] | 1687 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 1688 | .NOTPARALLEL: pass_$(pass)_order
|
---|
| 1689 | .PHONY: pass_$(pass)_order
|
---|
[219] | 1690 | pass_$(pass)_order: $(pass_prev)
|
---|
[353] | 1691 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
[219] | 1692 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
[353] | 1693 | else
|
---|
| 1694 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
[388] | 1695 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
[353] | 1696 | pass_$(pass)_banner:
|
---|
| 1697 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
| 1698 | pass_$(pass)_order: \
|
---|
| 1699 | $(pass_prev) \
|
---|
| 1700 | pass_$(pass)_banner \
|
---|
| 1701 | pass_$(pass)
|
---|
| 1702 | endif
|
---|
[219] | 1703 | $(eval pass_prev := pass_$(pass)_order)
|
---|
| 1704 | endef
|
---|
[183] | 1705 |
|
---|
[219] | 1706 | ## PASS: order
|
---|
| 1707 | # Use dependencies to ensure correct pass order.
|
---|
| 1708 | pass_prev :=
|
---|
[353] | 1709 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
| 1710 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 1711 | $(eval $(def_pass_order)))
|
---|
[219] | 1712 |
|
---|
[272] | 1713 |
|
---|
[75] | 1714 | #
|
---|
| 1715 | # THE MAIN RULES
|
---|
| 1716 | #
|
---|
[219] | 1717 | all_recursive: $(pass_prev)
|
---|
[75] | 1718 |
|
---|
[130] | 1719 | rebuild: clean
|
---|
[219] | 1720 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
[78] | 1721 |
|
---|
[412] | 1722 | # @todo make this a non-default pass!
|
---|
[353] | 1723 | uninstall:
|
---|
| 1724 | $(RM) -f $(_INSTALLS)
|
---|
[412] | 1725 |
|
---|
[380] | 1726 | install: pass_installs
|
---|
[78] | 1727 |
|
---|
[75] | 1728 | # misc shortcuts.
|
---|
[380] | 1729 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
[75] | 1730 | objects: $(_OBJS)
|
---|
[222] | 1731 | bldprogs: $(_BLDPROGS)
|
---|
[189] | 1732 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
[205] | 1733 | dlls: $(_DLLS)
|
---|
[219] | 1734 | programs: $(_PROGRAMS)
|
---|
[205] | 1735 | sysmods: $(_SYSMODS)
|
---|
[353] | 1736 | others: $(_OTHERS)
|
---|
[380] | 1737 | installs: $(_INSTALLS_DIRS) $(_INSTALLS)
|
---|
[75] | 1738 |
|
---|
| 1739 |
|
---|
[353] | 1740 | #
|
---|
| 1741 | # kBuild debugging stuff.
|
---|
| 1742 | #
|
---|
| 1743 | _SPACE := $(subst ., ,.)
|
---|
| 1744 | _TAB := $(subst ., ,.)
|
---|
| 1745 | define _NEWLINE
|
---|
| 1746 |
|
---|
| 1747 |
|
---|
| 1748 | endef
|
---|
| 1749 | NLTAB = $(_NEWLINE)$(TAB)
|
---|
| 1750 | show_targets:
|
---|
| 1751 | @$(foreach target, $(ALL_TARGETS),\
|
---|
| 1752 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
| 1753 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
| 1754 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
| 1755 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
[380] | 1756 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE) OBJS_ CLEAN, \
|
---|
[353] | 1757 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 1758 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
| 1759 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
| 1760 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
| 1761 | )\
|
---|
| 1762 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
| 1763 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 1764 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
| 1765 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
| 1766 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
| 1767 | ))
|
---|
| 1768 |
|
---|
| 1769 |
|
---|
| 1770 |
|
---|
| 1771 | #
|
---|
| 1772 | # Include dependency files.
|
---|
| 1773 | #
|
---|
| 1774 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
| 1775 |
|
---|
| 1776 |
|
---|
[72] | 1777 | # end-of-file-content
|
---|
[106] | 1778 | __footer_kmk__ := target
|
---|
[72] | 1779 | endif # __footer_kmk__
|
---|
[438] | 1780 |
|
---|