[72] | 1 | # $Id: footer.kmk 450 2006-06-14 03:46:23Z 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 | #
|
---|
[450] | 375 | _TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_PLATFORM)) $(TOOL)
|
---|
[72] | 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 | #
|
---|
[450] | 413 | _SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_PLATFORM)) $(SDKS)
|
---|
[72] | 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 |
|
---|
[450] | 439 | ## @todo SDKS.<> and TOOL.<> doesn't work correctly for BLDPROGS.
|
---|
[380] | 440 |
|
---|
[450] | 441 |
|
---|
[73] | 442 | #
|
---|
| 443 | # Object processing.
|
---|
| 444 | #
|
---|
[72] | 445 |
|
---|
[380] | 446 | ## wrapper the compile command dependency check.
|
---|
| 447 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
| 448 | _DEP_COMPILE_CMDS = $(if $(subst $(strip $($(target)_$(source)_CMDS_PREV_)),,$(strip $($(target)_$(source)_CMDS_))),FORCE,)
|
---|
| 449 | else
|
---|
| 450 | _DEP_COMPILE_CMDS =
|
---|
| 451 | endif
|
---|
| 452 |
|
---|
| 453 | ## Generates the rules for building a specific object, and the '::' aliases
|
---|
| 454 | # for building a source file.
|
---|
[353] | 455 | # @param $(obj) The object file.
|
---|
[380] | 456 | define def_target_source_rule
|
---|
| 457 | $(obj) $($(target)_$(source)_OUTPUT_): \
|
---|
| 458 | $($(target)_$(source)_DEPEND_) \
|
---|
| 459 | $(_DEP_COMPILE_CMDS) \
|
---|
| 460 | | \
|
---|
| 461 | $($(target)_$(source)_DEPORD_)
|
---|
| 462 | $(call MSG_L1,Creating $$@)
|
---|
| 463 | $(RM) -f $(dep) $(out) $($(target)_$(source)_OUTPUT_)
|
---|
| 464 | $(custom_pre)
|
---|
[412] | 465 |
|
---|
[380] | 466 | $($(target)_$(source)_CMDS_)
|
---|
| 467 |
|
---|
| 468 | $(custom_post)
|
---|
| 469 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
| 470 | @$(APPEND) "$(dep)"
|
---|
| 471 | @$(APPEND) "$(dep)" 'define $(target)_$(source)_CMDS_PREV_'
|
---|
| 472 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_$(source)_CMDS_))'
|
---|
| 473 | @$(APPEND) "$(dep)" 'endef'
|
---|
[412] | 474 | endif
|
---|
[380] | 475 |
|
---|
[353] | 476 | $(basename $(notdir $(obj))).o::
|
---|
[442] | 477 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
[445] | 478 | $(basename $(notdir $(obj))).obj::
|
---|
[442] | 479 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
[353] | 480 | endef
|
---|
[205] | 481 |
|
---|
[353] | 482 |
|
---|
[380] | 483 | ## wrapper the link command dependency check.
|
---|
| 484 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
| 485 | _DEP_LINK_CMDS = $(if $(subst $(strip $($(target)_CMDS_PREV_)),,$(strip $($(target)_CMDS_))),FORCE,)
|
---|
| 486 | else
|
---|
| 487 | _DEP_LINK_CMDS =
|
---|
| 488 | endif
|
---|
| 489 |
|
---|
| 490 | ## Generate the link rule for a target.
|
---|
| 491 | # @param $(target) The normalized target name.
|
---|
| 492 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
| 493 | # @param $(dep) The name of the dependency file.
|
---|
| 494 | # @param $(out)
|
---|
| 495 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
| 496 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
| 497 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
| 498 | # @param $($(target)_CMDS_) The link commands.
|
---|
| 499 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
| 500 | define def_link_rule
|
---|
| 501 | $(out) $($(target)_OUTPUT_): \
|
---|
| 502 | $($(target)_DEPEND_) \
|
---|
| 503 | $(_DEP_LINK_CMDS) \
|
---|
| 504 | | \
|
---|
| 505 | $($(target)_DEPORD_)
|
---|
| 506 | $(call MSG_L1,Creating $$@)
|
---|
| 507 | $(RM) -f $(dep) $($(target)_OUTPUT_)
|
---|
| 508 | $(custom_pre)
|
---|
[412] | 509 |
|
---|
[380] | 510 | $($(target)_CMDS_)
|
---|
| 511 |
|
---|
| 512 | $(custom_post)
|
---|
| 513 | ifndef NO_LINK_CMDS_DEP
|
---|
| 514 | @$(APPEND) "$(dep)" 'define $(target)_CMDS_PREV_'
|
---|
| 515 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_CMDS_))'
|
---|
| 516 | @$(APPEND) "$(dep)" 'endef'
|
---|
[412] | 517 | endif
|
---|
[380] | 518 |
|
---|
| 519 | $(basename $(notdir $(out)))::
|
---|
[442] | 520 | + $$(MAKE) -f $$(MAKEFILE) $(out)
|
---|
[380] | 521 | endef
|
---|
| 522 |
|
---|
| 523 |
|
---|
| 524 | ## Generate the link & lib install rule
|
---|
| 525 | # @param $(target) Normalized target name.
|
---|
| 526 | # @param $(out) The build target.
|
---|
| 527 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
| 528 | # @param $(mode) The file mode (optional)
|
---|
| 529 | define def_link_install_rule
|
---|
| 530 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
| 531 | $(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
| 532 | endef
|
---|
| 533 |
|
---|
| 534 |
|
---|
| 535 |
|
---|
[73] | 536 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 537 | # @param $(target) Normalized target name.
|
---|
| 538 | # @param $(source) Source file name.
|
---|
| 539 | # @param $(type) Source type. {C,CXX,AS}
|
---|
[221] | 540 | # @param bld_type Build type.
|
---|
| 541 | # @param bld_trg Build target.
|
---|
| 542 | # @param bld_trg_arch Build target arch.
|
---|
| 543 | # @param bld_trg_cpu Build target cpu.
|
---|
[72] | 544 | #
|
---|
[73] | 545 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
[105] | 546 | # @remark I now have a clue. Have to use $$ if not.
|
---|
[73] | 547 | define def_target_source_c_cpp_asm
|
---|
[105] | 548 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
[73] | 549 |
|
---|
[353] | 550 | tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
|
---|
| 551 | outbase := $(call _OBJECT_BASE,$(source),$(target))
|
---|
| 552 | PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 553 | dirdep := $(call DIRDEP,$(dir $(outbase)))
|
---|
| 554 | defs :=\
|
---|
[78] | 555 | $(TOOL_$(tool)_DEFS)\
|
---|
[221] | 556 | $(TOOL_$(tool)_DEFS.$(bld_type))\
|
---|
| 557 | $(TOOL_$(tool)_DEFS.$(bld_trg))\
|
---|
| 558 | $(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
|
---|
| 559 | $(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
|
---|
[74] | 560 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
[221] | 561 | $(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
|
---|
| 562 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
| 563 | $(SDKS.$(bld_type)) \
|
---|
[78] | 564 | $(SDKS),\
|
---|
[353] | 565 | $(SDK_$(sdk)_DEFS)\
|
---|
| 566 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 567 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 568 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
| 569 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 570 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 571 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 572 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 573 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 574 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 575 | $(DEFS)\
|
---|
[221] | 576 | $(DEFS.$(bld_type))\
|
---|
| 577 | $(DEFS.$(bld_trg))\
|
---|
| 578 | $(DEFS.$(bld_trg_arch))\
|
---|
| 579 | $(DEFS.$(bld_trg_cpu))\
|
---|
[78] | 580 | $($(type)DEFS)\
|
---|
[221] | 581 | $($(type)DEFS.$(bld_type))\
|
---|
| 582 | $($(type)DEFS.$(bld_trg))\
|
---|
| 583 | $($(type)DEFS.$(bld_trg_arch))\
|
---|
| 584 | $($(type)DEFS.$(bld_trg_cpu))\
|
---|
| 585 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
| 586 | $($(target)_SDKS.$(bld_type)) \
|
---|
[78] | 587 | $($(target)_SDKS),\
|
---|
[353] | 588 | $(SDK_$(sdk)_DEFS)\
|
---|
| 589 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 590 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 591 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
| 592 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 593 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 594 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 595 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 596 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 597 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 598 | $($(target)_DEFS)\
|
---|
[221] | 599 | $($(target)_DEFS.$(bld_type))\
|
---|
| 600 | $($(target)_DEFS.$(bld_trg))\
|
---|
| 601 | $($(target)_DEFS.$(bld_trg_arch))\
|
---|
| 602 | $($(target)_DEFS.$(bld_trg_cpu))\
|
---|
[78] | 603 | $($(target)_$(type)DEFS)\
|
---|
[221] | 604 | $($(target)_$(type)DEFS.$(bld_type))\
|
---|
| 605 | $($(target)_$(type)DEFS.$(bld_trg))\
|
---|
| 606 | $($(target)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 607 | $($(target)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
| 608 | $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
|
---|
| 609 | $($(source)_SDKS.$(bld_type)) \
|
---|
[78] | 610 | $($(source)_SDKS),\
|
---|
[353] | 611 | $(SDK_$(sdk)_DEFS)\
|
---|
| 612 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 613 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 614 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
| 615 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 616 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 617 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 618 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 619 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 620 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 621 | $($(source)_DEFS)\
|
---|
[221] | 622 | $($(source)_DEFS.$(bld_type))\
|
---|
| 623 | $($(source)_DEFS.$(bld_trg))\
|
---|
| 624 | $($(source)_DEFS.$(bld_trg_arch))\
|
---|
| 625 | $($(source)_DEFS.$(bld_trg_cpu))\
|
---|
[73] | 626 | $($(source)_$(type)DEFS)\
|
---|
[221] | 627 | $($(source)_$(type)DEFS.$(bld_type))\
|
---|
| 628 | $($(source)_$(type)DEFS.$(bld_trg))\
|
---|
| 629 | $($(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 630 | $($(source)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
| 631 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
| 632 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
[78] | 633 | $($(target)_$(source)_SDKS),\
|
---|
[353] | 634 | $(SDK_$(sdk)_DEFS)\
|
---|
| 635 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
| 636 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
| 637 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
| 638 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
| 639 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
| 640 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
| 641 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
| 642 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
| 643 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
[74] | 644 | $($(target)_$(source)_DEFS)\
|
---|
[221] | 645 | $($(target)_$(source)_DEFS.$(bld_type))\
|
---|
| 646 | $($(target)_$(source)_DEFS.$(bld_trg))\
|
---|
| 647 | $($(target)_$(source)_DEFS.$(bld_trg_arch))\
|
---|
| 648 | $($(target)_$(source)_DEFS.$(bld_trg_cpu))\
|
---|
[74] | 649 | $($(target)_$(source)_$(type)DEFS)\
|
---|
[221] | 650 | $($(target)_$(source)_$(type)DEFS.$(bld_type))\
|
---|
| 651 | $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
|
---|
| 652 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
[353] | 653 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
|
---|
| 654 | incs :=\
|
---|
[221] | 655 | $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 656 | $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 657 | $($(target)_$(source)_$(type)INCS.$(bld_trg))\
|
---|
| 658 | $($(target)_$(source)_$(type)INCS.$(bld_type))\
|
---|
[73] | 659 | $($(target)_$(source)_$(type)INCS)\
|
---|
[221] | 660 | $($(target)_$(source)_INCS.$(bld_trg_cpu))\
|
---|
| 661 | $($(target)_$(source)_INCS.$(bld_trg_arch))\
|
---|
| 662 | $($(target)_$(source)_INCS.$(bld_trg))\
|
---|
| 663 | $($(target)_$(source)_INCS.$(bld_type))\
|
---|
[73] | 664 | $($(target)_$(source)_INCS)\
|
---|
[221] | 665 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
| 666 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
[133] | 667 | $($(target)_$(source)_SDKS),\
|
---|
[353] | 668 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 669 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 670 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 671 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 672 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 673 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
| 674 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 675 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 676 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 677 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 678 | $($(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 679 | $($(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 680 | $($(source)_$(type)INCS.$(bld_trg))\
|
---|
| 681 | $($(source)_$(type)INCS.$(bld_type))\
|
---|
[73] | 682 | $($(source)_$(type)INCS)\
|
---|
[221] | 683 | $($(source)_INCS.$(bld_trg_cpu))\
|
---|
| 684 | $($(source)_INCS.$(bld_trg_arch))\
|
---|
| 685 | $($(source)_INCS.$(bld_trg))\
|
---|
| 686 | $($(source)_INCS.$(bld_type))\
|
---|
[73] | 687 | $($(source)_INCS)\
|
---|
[221] | 688 | $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
|
---|
| 689 | $($(source)_SDKS.$(bld_type)) \
|
---|
[78] | 690 | $($(source)_SDKS),\
|
---|
[353] | 691 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 692 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 693 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 694 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 695 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 696 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
| 697 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 698 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 699 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 700 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 701 | $($(target)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 702 | $($(target)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 703 | $($(target)_$(type)INCS.$(bld_trg))\
|
---|
| 704 | $($(target)_$(type)INCS.$(bld_type))\
|
---|
[73] | 705 | $($(target)_$(type)INCS)\
|
---|
[221] | 706 | $($(target)_INCS.$(bld_trg_cpu))\
|
---|
| 707 | $($(target)_INCS.$(bld_trg_arch))\
|
---|
| 708 | $($(target)_INCS.$(bld_trg))\
|
---|
| 709 | $($(target)_INCS.$(bld_type))\
|
---|
[73] | 710 | $($(target)_INCS)\
|
---|
[221] | 711 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
| 712 | $($(target)_SDKS.$(bld_type)) \
|
---|
[78] | 713 | $($(target)_SDKS),\
|
---|
[353] | 714 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 715 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 716 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 717 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 718 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 719 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
| 720 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 721 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 722 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 723 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 724 | $(INCS.$(bld_trg_cpu))\
|
---|
| 725 | $(INCS.$(bld_trg_arch))\
|
---|
| 726 | $(INCS.$(bld_trg))\
|
---|
| 727 | $(INCS.$(bld_type))\
|
---|
[73] | 728 | $(INCS)\
|
---|
[221] | 729 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
| 730 | $(SDKS.$(bld_type)) \
|
---|
[78] | 731 | $(SDKS),\
|
---|
[353] | 732 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 733 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 734 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
| 735 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
| 736 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
| 737 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
| 738 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
| 739 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
| 740 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
| 741 | $(SDK_$(sdk)_INCS))\
|
---|
[221] | 742 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
|
---|
| 743 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
|
---|
| 744 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
|
---|
| 745 | $(TOOL_$(tool)_$(type)INCS.$(bld_type))\
|
---|
[353] | 746 | $(TOOL_$(tool)_$(type)INCS)
|
---|
| 747 | flags :=\
|
---|
[73] | 748 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
[221] | 749 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
|
---|
| 750 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
|
---|
| 751 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
| 752 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 753 | $($(type)FLAGS)\
|
---|
[221] | 754 | $($(type)FLAGS.$(bld_type))\
|
---|
| 755 | $($(type)FLAGS.$(bld_trg))\
|
---|
| 756 | $($(type)FLAGS.$(bld_trg_arch))\
|
---|
| 757 | $($(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 758 | $($(target)_$(type)FLAGS)\
|
---|
[221] | 759 | $($(target)_$(type)FLAGS.$(bld_type))\
|
---|
| 760 | $($(target)_$(type)FLAGS.$(bld_trg))\
|
---|
| 761 | $($(target)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
| 762 | $($(target)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 763 | $($(source)_$(type)FLAGS)\
|
---|
[221] | 764 | $($(source)_$(type)FLAGS.$(bld_type))\
|
---|
| 765 | $($(source)_$(type)FLAGS.$(bld_trg))\
|
---|
| 766 | $($(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
| 767 | $($(source)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
[73] | 768 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
[221] | 769 | $($(target)_$(source)_$(type)FLAGS.$(bld_type))\
|
---|
| 770 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
|
---|
| 771 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
[353] | 772 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
|
---|
| 773 | objsuff := $(firstword \
|
---|
[221] | 774 | $($(target)_$(source)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 775 | $($(target)_$(source)_OBJSUFF)\
|
---|
[221] | 776 | $($(source)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 777 | $($(source)_OBJSUFF)\
|
---|
[221] | 778 | $($(target)_OBJSUFF.$(bld_trg))\
|
---|
[74] | 779 | $($(target)_OBJSUFF)\
|
---|
[221] | 780 | $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
|
---|
[74] | 781 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
[353] | 782 | $(SUFF_OBJ))
|
---|
| 783 | obj := $(outbase)$(objsuff)
|
---|
| 784 | deps := \
|
---|
[184] | 785 | $($(target)_$(source)_DEPS)\
|
---|
[353] | 786 | $($(target)_$(source)_DEPS.$(bld_type))\
|
---|
| 787 | $($(target)_$(source)_DEPS.$(bld_trg))\
|
---|
| 788 | $($(target)_$(source)_DEPS.$(bld_trg_arch))\
|
---|
| 789 | $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
|
---|
[184] | 790 | $($(source)_DEPS)\
|
---|
[221] | 791 | $($(source)_DEPS.$(bld_type))\
|
---|
| 792 | $($(source)_DEPS.$(bld_trg))\
|
---|
[353] | 793 | $($(source)_DEPS.$(bld_trg_arch))\
|
---|
| 794 | $($(source)_DEPS.$(bld_trg_cpu))\
|
---|
[184] | 795 | $($(target)_DEPS)\
|
---|
[353] | 796 | $($(target)_DEPS.$(bld_type))\
|
---|
[221] | 797 | $($(target)_DEPS.$(bld_trg_arch))\
|
---|
[353] | 798 | $($(target)_DEPS.$(bld_trg_cpu))
|
---|
[73] | 799 |
|
---|
[380] | 800 | # dependencies
|
---|
| 801 | dep := $(obj)$(SUFF_DEP)
|
---|
| 802 | ifndef NO_COMPILE_DEPS
|
---|
| 803 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 804 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 805 | endif
|
---|
[184] | 806 |
|
---|
| 807 | #$ (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] | 808 | ifndef TOOL_$(tool)_COMPILE_$(type)_CMDS
|
---|
[353] | 809 | $(warning kBuild: tools: \
|
---|
[221] | 810 | 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 811 | 2 $($(target)_$(source)_$(type)TOOL) \
|
---|
[221] | 812 | 3 $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
[106] | 813 | 4 $($(target)_$(source)_TOOL) \
|
---|
[221] | 814 | 5 $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 815 | 6 $($(target)_$(type)TOOL) \
|
---|
[221] | 816 | 7 $($(target)_TOOL.$(bld_trg)) \
|
---|
[106] | 817 | 8 $($(target)_TOOL) \
|
---|
[221] | 818 | 9 $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
[106] | 819 | 10 $($(source)_$(type)TOOL) \
|
---|
[221] | 820 | 11 $($(source)_TOOL.$(bld_trg)) \
|
---|
[106] | 821 | 12 $($(source)_TOOL) \
|
---|
[221] | 822 | 13 $($(type)TOOL.$(bld_trg)) \
|
---|
[106] | 823 | 14 $($(type)TOOL) \
|
---|
[221] | 824 | 15 $(TOOL.$(bld_trg)) \
|
---|
[106] | 825 | 16 $(TOOL) )
|
---|
[380] | 826 | $(error kBuild: TOOL_$(tool)_COMPILE_$(type)_CMDS is not defined. source=$(source) target=$(target) )
|
---|
[97] | 827 | endif
|
---|
[353] | 828 |
|
---|
[380] | 829 | # call the tool
|
---|
| 830 | $(target)_$(source)_CMDS_ := $(TOOL_$(tool)_COMPILE_$(type)_CMDS)
|
---|
| 831 | $(target)_$(source)_OUTPUT_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT)
|
---|
| 832 | $(target)_$(source)_DEPEND_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPEND) $(deps) $(source)
|
---|
| 833 | $(target)_$(source)_DEPORD_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPORD) $(dirdep)
|
---|
[73] | 834 |
|
---|
[380] | 835 | # generate the compile rule.
|
---|
| 836 | $(eval $(def_target_source_rule))
|
---|
[205] | 837 |
|
---|
[380] | 838 | _OUT_FILES += $($(target)_$(source)_OUTPUT_)
|
---|
[353] | 839 | $(target)_OBJS_ += $(obj)
|
---|
[73] | 840 |
|
---|
| 841 | endef
|
---|
| 842 |
|
---|
| 843 | ## Generic macro for processing all target sources.
|
---|
[74] | 844 | # @param $(target) Normalized target name.
|
---|
[73] | 845 | define def_target_sources
|
---|
| 846 | #$ (warning def_target_sources)
|
---|
| 847 | # C sources
|
---|
[353] | 848 | type := C
|
---|
| 849 | $(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
| 850 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
[73] | 851 |
|
---|
| 852 | # C++ sources
|
---|
[353] | 853 | type := CXX
|
---|
| 854 | $(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)))\
|
---|
| 855 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
[73] | 856 |
|
---|
| 857 | # ASM sources
|
---|
[353] | 858 | type := AS
|
---|
| 859 | $(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)))\
|
---|
| 860 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
| 861 |
|
---|
[73] | 862 | endef
|
---|
| 863 |
|
---|
| 864 |
|
---|
[219] | 865 |
|
---|
[353] | 866 | ## Generic macro for generating the install rule(s) for a target
|
---|
| 867 | # and update the globals with default out.
|
---|
[219] | 868 | #
|
---|
[353] | 869 | # @param $(target) Normalized target name.
|
---|
| 870 | # @param $(out) The output file.
|
---|
| 871 | # @param $(definst) The default _INST value.
|
---|
| 872 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
| 873 | # @obsolete
|
---|
| 874 | define def_target_install_pluss
|
---|
| 875 | ifndef $(target)_NOINST
|
---|
| 876 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 877 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
[219] | 878 |
|
---|
[353] | 879 | $(eval $(def_link_install_rule))
|
---|
[239] | 880 |
|
---|
[353] | 881 | _INSTALLS += $(INSTARGET_$(target))
|
---|
[272] | 882 |
|
---|
[353] | 883 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
| 884 | $(typevar) += $(INSTARGET_$(target))
|
---|
[219] | 885 | else
|
---|
[353] | 886 | $(typevar) += $(out)
|
---|
[219] | 887 | endif
|
---|
[353] | 888 | else # _NOINST
|
---|
| 889 | $(typevar) += $(out)
|
---|
| 890 | endif
|
---|
| 891 |
|
---|
| 892 | _OUT_FILES += $(out)
|
---|
| 893 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
| 894 | _OBJS += $($(target)_OBJS_)
|
---|
| 895 |
|
---|
[219] | 896 | endef
|
---|
| 897 |
|
---|
| 898 |
|
---|
| 899 |
|
---|
| 900 | #
|
---|
[72] | 901 | # LIBRARIES
|
---|
[73] | 902 | #
|
---|
[72] | 903 |
|
---|
| 904 | ## Library (one).
|
---|
[74] | 905 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 906 | define def_lib
|
---|
[145] | 907 | # library basics
|
---|
[222] | 908 | ## @todo prefix
|
---|
[353] | 909 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 910 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 911 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 912 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 913 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
[78] | 914 | ifeq ($(tool),)
|
---|
[353] | 915 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
[78] | 916 | endif
|
---|
[353] | 917 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 918 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 919 | suff := $(firstword\
|
---|
[221] | 920 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
[126] | 921 | $($(target)_LIBSUFF)\
|
---|
[221] | 922 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
[126] | 923 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
[353] | 924 | $(SUFF_LIB))
|
---|
| 925 | out := $(outbase)$(suff)
|
---|
| 926 | TARGET_$(target) := $(out)
|
---|
| 927 | $(target)_OBJS_ := $(filter %.o %.obj, \
|
---|
| 928 | $($(target)_SOURCES) \
|
---|
| 929 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 930 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 931 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 932 | $($(target)_SOURCES.$(bld_type)))
|
---|
[145] | 933 |
|
---|
[353] | 934 |
|
---|
[145] | 935 | # source -> object
|
---|
[353] | 936 | $(eval $(value def_target_sources))
|
---|
[145] | 937 |
|
---|
| 938 | # library linking
|
---|
[353] | 939 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
| 940 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 941 | flags :=\
|
---|
[74] | 942 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
[221] | 943 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
[74] | 944 | $(ARFLAGS)\
|
---|
[221] | 945 | $(ARFLAGS.$(bld_type))\
|
---|
[74] | 946 | $($(target)_ARFLAGS)\
|
---|
[353] | 947 | $($(target)_ARFLAGS.$(bld_type))
|
---|
| 948 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
| 949 | $($(target)_SOURCES) \
|
---|
| 950 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 951 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 952 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 953 | $($(target)_SOURCES.$(bld_type)))
|
---|
| 954 | objs = $($(target)_OBJS_)
|
---|
| 955 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
[78] | 956 | ## @todo fix dependencies on makefiles an such
|
---|
[353] | 957 | deps := $($(target)_DEPS)
|
---|
[72] | 958 |
|
---|
[380] | 959 | # dependency file
|
---|
| 960 | dep := $(out)$(SUFF_DEP)
|
---|
| 961 | ifndef NO_LINK_CMDS_DEP
|
---|
| 962 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 963 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 964 | endif
|
---|
[72] | 965 |
|
---|
[380] | 966 | # check that the tool is defined.
|
---|
| 967 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
| 968 | $(warning kBuild: tools: \
|
---|
| 969 | 1 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 970 | 2 $($(target)_$(source)TOOL) \
|
---|
| 971 | 3 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 972 | 4 $($(target)_TOOL) \
|
---|
| 973 | 5 $($(source)TOOL) \
|
---|
| 974 | 6 $($(source)TOOL.$(bld_trg)) \
|
---|
| 975 | 7 $(TOOL.$(bld_trg)) \
|
---|
| 976 | 8 $(TOOL) )
|
---|
| 977 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
| 978 | endif
|
---|
| 979 |
|
---|
| 980 | # call the tool
|
---|
| 981 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
| 982 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
| 983 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $(objs)
|
---|
| 984 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep)
|
---|
| 985 |
|
---|
[412] | 986 | # generate the link rule.
|
---|
[380] | 987 | $(eval $(def_link_rule))
|
---|
| 988 |
|
---|
[353] | 989 | # installing and globals
|
---|
| 990 | definst := $(PATH_LIB)
|
---|
[380] | 991 | typevar := _LIBS
|
---|
[353] | 992 | $(eval $(value def_target_install_pluss))
|
---|
[72] | 993 | endef
|
---|
| 994 |
|
---|
| 995 | # Process libraries
|
---|
[380] | 996 | mode := 0644
|
---|
[353] | 997 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(value def_lib)))
|
---|
[72] | 998 |
|
---|
| 999 |
|
---|
| 1000 | #
|
---|
[353] | 1001 | # Link operations.
|
---|
[72] | 1002 | #
|
---|
| 1003 |
|
---|
[353] | 1004 | ##
|
---|
| 1005 | # Link prolog
|
---|
| 1006 | #
|
---|
| 1007 | # @param $(target) Normalized target name.
|
---|
| 1008 | # @param $(EXT) EXE,DLL,SYS.
|
---|
| 1009 | # @param $(definst) The default _INST value.
|
---|
| 1010 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
[380] | 1011 | define def_link_common
|
---|
[353] | 1012 | # basics
|
---|
| 1013 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1014 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
| 1015 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
| 1016 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
[145] | 1017 |
|
---|
[353] | 1018 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
| 1019 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 1020 | suff := $(firstword \
|
---|
| 1021 | $($(target)_$(EXT)SUFF) \
|
---|
| 1022 | $($(target)_$(EXT)SUFF) \
|
---|
| 1023 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
| 1024 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
| 1025 | out := $(outbase)$(suff)
|
---|
| 1026 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 1027 | TARGET_$(target) := $(out)
|
---|
| 1028 | $(target)_OBJS_ := $(filter %.o %.obj, \
|
---|
| 1029 | $($(target)_SOURCES) \
|
---|
| 1030 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1031 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 1032 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1033 | $($(target)_SOURCES.$(bld_type)))
|
---|
| 1034 |
|
---|
[145] | 1035 | # source -> object
|
---|
[353] | 1036 | $(eval $(value def_target_sources))
|
---|
[145] | 1037 |
|
---|
[353] | 1038 | # more library stuff.
|
---|
| 1039 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
| 1040 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
| 1041 | flags :=\
|
---|
[74] | 1042 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
[221] | 1043 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
| 1044 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
| 1045 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
| 1046 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
[74] | 1047 | $(LDFLAGS)\
|
---|
[221] | 1048 | $(LDFLAGS.$(bld_type))\
|
---|
| 1049 | $(LDFLAGS.$(bld_trg))\
|
---|
| 1050 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
| 1051 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
[74] | 1052 | $($(target)_LDFLAGS)\
|
---|
[221] | 1053 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
| 1054 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
| 1055 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
[353] | 1056 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
| 1057 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
| 1058 | $($(target)_SOURCES)\
|
---|
| 1059 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1060 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 1061 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1062 | $($(target)_SOURCES.$(bld_type)))
|
---|
| 1063 | objs = $($(target)_OBJS_)
|
---|
| 1064 | libs :=\
|
---|
[221] | 1065 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
| 1066 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
| 1067 | $($(target)_LIBS.$(bld_trg))\
|
---|
| 1068 | $($(target)_LIBS.$(bld_type))\
|
---|
[74] | 1069 | $($(target)_LIBS)\
|
---|
[221] | 1070 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1071 | $($(target)_SDKS.$(bld_type)) \
|
---|
[122] | 1072 | $($(target)_SDKS),\
|
---|
[353] | 1073 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
| 1074 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 1075 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 1076 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 1077 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 1078 | $(LIBS.$(bld_trg_cpu))\
|
---|
| 1079 | $(LIBS.$(bld_trg_arch))\
|
---|
| 1080 | $(LIBS.$(bld_trg))\
|
---|
| 1081 | $(LIBS.$(bld_type))\
|
---|
[74] | 1082 | $(LIBS)\
|
---|
[221] | 1083 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
| 1084 | $(SDKS.$(bld_type)) \
|
---|
[122] | 1085 | $(SDKS),\
|
---|
[353] | 1086 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
| 1087 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 1088 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 1089 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 1090 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 1091 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
| 1092 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
| 1093 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
| 1094 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
[353] | 1095 | $(TOOL_$(tool)_LIBS)
|
---|
| 1096 | libpath :=\
|
---|
[221] | 1097 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
| 1098 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1099 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
| 1100 | $($(target)_LIBPATH.$(bld_type))\
|
---|
[74] | 1101 | $($(target)_LIBPATH)\
|
---|
[221] | 1102 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1103 | $($(target)_SDKS.$(bld_type)) \
|
---|
[122] | 1104 | $($(target)_SDKS),\
|
---|
[353] | 1105 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
| 1106 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1107 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 1108 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 1109 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 1110 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
| 1111 | $(LIBPATH.$(bld_trg_arch))\
|
---|
| 1112 | $(LIBPATH.$(bld_trg))\
|
---|
| 1113 | $(LIBPATH.$(bld_type))\
|
---|
[74] | 1114 | $(LIBPATH)\
|
---|
[221] | 1115 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
| 1116 | $(SDKS.$(bld_type)) \
|
---|
[122] | 1117 | $(SDKS),\
|
---|
[353] | 1118 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
| 1119 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1120 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 1121 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 1122 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 1123 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
| 1124 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1125 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
| 1126 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
[353] | 1127 | $(TOOL_$(tool)_LIBPATH)
|
---|
| 1128 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
[74] | 1129 | ## @todo fix dependencies
|
---|
[353] | 1130 | deps := $($(target)_DEPS)
|
---|
| 1131 |
|
---|
| 1132 | ## @todo this stuff can't be working.
|
---|
| 1133 | custom_pre := $(strip $(firstword \
|
---|
[221] | 1134 | $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
| 1135 | $($(target)_CUSTOM_PRE.$(bld_trg))\
|
---|
| 1136 | $($(target)_CUSTOM_PRE.$(bld_type))\
|
---|
[74] | 1137 | $($(target)_CUSTOM_PRE)\
|
---|
[221] | 1138 | $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
| 1139 | $(CUSTOM_PRE.$(bld_trg))\
|
---|
| 1140 | $(CUSTOM_PRE.$(bld_type))\
|
---|
[74] | 1141 | $(CUSTOM_PRE)\
|
---|
[353] | 1142 | ))
|
---|
| 1143 | custom_post := $(strip $(firstword \
|
---|
[221] | 1144 | $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
| 1145 | $($(target)_CUSTOM_POST.$(bld_trg))\
|
---|
| 1146 | $($(target)_CUSTOM_POST.$(bld_type))\
|
---|
[74] | 1147 | $($(target)_CUSTOM_POST)\
|
---|
[221] | 1148 | $(CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
| 1149 | $(CUSTOM_POST.$(bld_trg))\
|
---|
| 1150 | $(CUSTOM_POST.$(bld_type))\
|
---|
[74] | 1151 | $(CUSTOM_POST)\
|
---|
[353] | 1152 | ))
|
---|
[72] | 1153 |
|
---|
[353] | 1154 | # installation targets
|
---|
| 1155 | ifndef $(target)_NOINST
|
---|
| 1156 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 1157 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
| 1158 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
| 1159 | $(typevar) += $(INSTARGET_$(target))
|
---|
| 1160 | else
|
---|
| 1161 | $(typevar) += $(out)
|
---|
| 1162 | endif
|
---|
| 1163 | # generate the install rule
|
---|
| 1164 | $(eval $(def_link_install_rule))
|
---|
| 1165 |
|
---|
| 1166 | else # NOINST
|
---|
| 1167 | INSTARGET_$(target) :=
|
---|
| 1168 | $(typevar) += $(out)
|
---|
| 1169 | endif # NOINST
|
---|
| 1170 |
|
---|
[380] | 1171 | # dependency file
|
---|
| 1172 | dep := $(outbase)$(SUFF_DEP)
|
---|
| 1173 | ifndef NO_LINK_CMDS_DEP
|
---|
| 1174 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 1175 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
| 1176 | endif
|
---|
[353] | 1177 |
|
---|
[380] | 1178 | # check that the tool is defined.
|
---|
| 1179 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
| 1180 | $(warning kBuild: tools: \
|
---|
| 1181 | 1 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 1182 | 2 $($(target)_$(source)TOOL) \
|
---|
| 1183 | 3 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 1184 | 4 $($(target)_TOOL) \
|
---|
| 1185 | 5 $($(source)TOOL) \
|
---|
| 1186 | 6 $($(source)TOOL.$(bld_trg)) \
|
---|
| 1187 | 7 $(TOOL.$(bld_trg)) \
|
---|
| 1188 | 8 $(TOOL) )
|
---|
| 1189 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
| 1190 | endif
|
---|
[353] | 1191 |
|
---|
[380] | 1192 | # call the tool
|
---|
| 1193 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
| 1194 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
| 1195 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $(objs)
|
---|
| 1196 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep)
|
---|
[353] | 1197 |
|
---|
[412] | 1198 | # generate the link rule.
|
---|
[380] | 1199 | $(eval $(def_link_rule))
|
---|
| 1200 |
|
---|
[412] | 1201 |
|
---|
[380] | 1202 | # Update globals.
|
---|
[353] | 1203 | _OBJS += $($(target)_OBJS_)
|
---|
[380] | 1204 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
[353] | 1205 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
[380] | 1206 | _INSTALLS += $(INSTARGET_$(target))
|
---|
[353] | 1207 |
|
---|
| 1208 | endef
|
---|
| 1209 |
|
---|
| 1210 |
|
---|
| 1211 | #
|
---|
| 1212 | # BLDPROGS
|
---|
| 1213 | #
|
---|
| 1214 |
|
---|
| 1215 | ## Build program (one).
|
---|
| 1216 | # @param $(target) Normalized target (program) name.
|
---|
| 1217 | define def_bldprog
|
---|
| 1218 |
|
---|
| 1219 | # set NOINST if not forced installation.
|
---|
| 1220 | ifndef $(target)_INST
|
---|
| 1221 | $(target)_NOINST := 1
|
---|
| 1222 | endif
|
---|
| 1223 |
|
---|
[380] | 1224 | # do the usual stuff.
|
---|
| 1225 | $(eval $(value def_link_common))
|
---|
[353] | 1226 |
|
---|
| 1227 | endef
|
---|
| 1228 |
|
---|
| 1229 | # Process build programs.
|
---|
| 1230 | EXT := EXE
|
---|
| 1231 | EXTPRE := HOST
|
---|
[380] | 1232 | tool_do := LINK_PROGRAM
|
---|
[353] | 1233 | definst := $(PATH_BIN)
|
---|
| 1234 | typevar := _BLDPROGS
|
---|
[380] | 1235 | mode := 0755
|
---|
[353] | 1236 | bld_trg_base_var := PLATFORM
|
---|
| 1237 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(value def_bldprog)))
|
---|
| 1238 |
|
---|
| 1239 |
|
---|
| 1240 |
|
---|
| 1241 | #
|
---|
| 1242 | # DLLS
|
---|
| 1243 | #
|
---|
| 1244 |
|
---|
[189] | 1245 | # Process dlls
|
---|
[353] | 1246 | EXT := DLL
|
---|
| 1247 | EXTPRE :=
|
---|
[380] | 1248 | tool_do := LINK_DLL
|
---|
[353] | 1249 | definst := $(PATH_DLL)
|
---|
| 1250 | typevar := _DLLS
|
---|
[380] | 1251 | mode := 0755
|
---|
[353] | 1252 | bld_trg_base_var := TARGET
|
---|
[380] | 1253 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
[74] | 1254 |
|
---|
| 1255 |
|
---|
[72] | 1256 | #
|
---|
[189] | 1257 | # Process import libraries.
|
---|
[72] | 1258 | #
|
---|
[219] | 1259 | # - On OS/2 and windows these are libraries.
|
---|
[189] | 1260 | # - On other platforms they are fake DLLs.
|
---|
[438] | 1261 | ifeq ($(filter-out win64 win32 os2,$(BUILD_TARGET)),)
|
---|
[353] | 1262 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_lib)))
|
---|
[189] | 1263 | else
|
---|
[380] | 1264 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
[189] | 1265 | endif
|
---|
[353] | 1266 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), \
|
---|
| 1267 | $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
|
---|
[72] | 1268 |
|
---|
[189] | 1269 |
|
---|
| 1270 | #
|
---|
| 1271 | # PROGRAMS
|
---|
| 1272 | #
|
---|
| 1273 |
|
---|
[353] | 1274 | # Process programs
|
---|
| 1275 | EXT := EXE
|
---|
| 1276 | EXTPRE :=
|
---|
[380] | 1277 | tool_do := LINK_PROGRAM
|
---|
[353] | 1278 | definst := $(PATH_BIN)
|
---|
| 1279 | typevar := _PROGRAMS
|
---|
[380] | 1280 | mode := 0755
|
---|
[353] | 1281 | bld_trg_base_var := TARGET
|
---|
[380] | 1282 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
[130] | 1283 |
|
---|
| 1284 |
|
---|
[189] | 1285 |
|
---|
[72] | 1286 | #
|
---|
[83] | 1287 | # SYSMODS
|
---|
[72] | 1288 | #
|
---|
| 1289 |
|
---|
[130] | 1290 | # Process sysmods
|
---|
[353] | 1291 | EXT := SYS
|
---|
| 1292 | EXTPRE :=
|
---|
[380] | 1293 | tool_do := LINK_SYSMOD
|
---|
[353] | 1294 | definst := $(PATH_SYS)
|
---|
| 1295 | typevar := _SYSMODS
|
---|
[380] | 1296 | mode := 0644
|
---|
[353] | 1297 | bld_trg_base_var := TARGET
|
---|
[380] | 1298 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
[83] | 1299 |
|
---|
| 1300 |
|
---|
[72] | 1301 | #
|
---|
| 1302 | # OTHERS
|
---|
| 1303 | #
|
---|
[190] | 1304 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
[72] | 1305 |
|
---|
| 1306 |
|
---|
[353] | 1307 | #
|
---|
| 1308 | # INSTALLS
|
---|
| 1309 | #
|
---|
[72] | 1310 |
|
---|
[353] | 1311 | ## generate the install rule
|
---|
| 1312 | define def_install_src_rule
|
---|
| 1313 | # the install rule
|
---|
| 1314 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
[380] | 1315 | $$(if $$(filter $(INSTALL),$(inscmd)),,$$(RM) -f $$@)
|
---|
[353] | 1316 | $(inscmd)
|
---|
| 1317 | endef
|
---|
| 1318 |
|
---|
| 1319 | ## install one file
|
---|
| 1320 | define def_install_src
|
---|
| 1321 |
|
---|
| 1322 | # deal with '=>' in the source file name.
|
---|
| 1323 | srcdst := $(subst =>, ,$(src))
|
---|
| 1324 | srcsrc := $(firstword $(srcdst))
|
---|
[424] | 1325 | srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
[353] | 1326 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
| 1327 |
|
---|
| 1328 | # _INSTFUN
|
---|
| 1329 | ifdef $(srcsrc)_INSTFUN
|
---|
| 1330 | instfun := $(srcsrc)_INSTFUN
|
---|
| 1331 | else
|
---|
| 1332 | ifdef $(target)_INSTFUN
|
---|
| 1333 | instfun := $(target)_INSTFUN
|
---|
| 1334 | else
|
---|
| 1335 | instfun := _INSTALL_FILE
|
---|
| 1336 | endif
|
---|
| 1337 | endif
|
---|
| 1338 |
|
---|
| 1339 | # _INST
|
---|
| 1340 | ifdef $(srcsrc)_INST
|
---|
[424] | 1341 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
---|
[353] | 1342 | else
|
---|
| 1343 | ifdef $(target)_INST
|
---|
[424] | 1344 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
---|
[353] | 1345 | else
|
---|
[424] | 1346 | inst := $(dir $(srcdstdir))
|
---|
[353] | 1347 | endif
|
---|
| 1348 | endif
|
---|
| 1349 |
|
---|
| 1350 | # calc target
|
---|
[380] | 1351 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
[424] | 1352 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
---|
[353] | 1353 |
|
---|
[414] | 1354 | # mode, uid and gid
|
---|
| 1355 | mode := $(firstword \
|
---|
| 1356 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 1357 | $($(target)_$(srcsrc)_MODE) \
|
---|
| 1358 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
| 1359 | $($(target)_$(srcdst)_MODE) \
|
---|
| 1360 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 1361 | $($(srcsrc)_MODE) \
|
---|
| 1362 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
| 1363 | $($(srcdst)_MODE) \
|
---|
| 1364 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 1365 | $($(target)_MODE))
|
---|
| 1366 | uid := $(firstword \
|
---|
| 1367 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
| 1368 | $($(target)_$(srcsrc)_UID) \
|
---|
| 1369 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
| 1370 | $($(target)_$(srcdst)_UID) \
|
---|
| 1371 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
| 1372 | $($(srcsrc)_UID) \
|
---|
| 1373 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
| 1374 | $($(srcdst)_UID) \
|
---|
| 1375 | $($(target)_UID.$(bld_trg)) \
|
---|
| 1376 | $($(target)_UID))
|
---|
| 1377 | gid := $(firstword \
|
---|
| 1378 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
| 1379 | $($(target)_$(srcsrc)_GID) \
|
---|
| 1380 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
| 1381 | $($(target)_$(srcdst)_GID) \
|
---|
| 1382 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
| 1383 | $($(srcsrc)_GID) \
|
---|
| 1384 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
| 1385 | $($(srcdst)_GID) \
|
---|
| 1386 | $($(target)_GID.$(bld_trg)) \
|
---|
| 1387 | $($(target)_GID))
|
---|
| 1388 |
|
---|
[353] | 1389 | # create the command
|
---|
| 1390 | ifdef $(srcsrc)_INSTALLER
|
---|
| 1391 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
| 1392 | else
|
---|
| 1393 | ifdef $(target)_INSTALLER
|
---|
| 1394 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
| 1395 | else
|
---|
[414] | 1396 | inscmd := $$(INSTALL)\
|
---|
| 1397 | $(if $(uid),-o $(uid))\
|
---|
| 1398 | $(if $(gid),-g $(gid))\
|
---|
| 1399 | $(if $(mode),-m $(mode))\
|
---|
| 1400 | $(srcsrc) $(insdst)
|
---|
[353] | 1401 | endif
|
---|
| 1402 | endif
|
---|
| 1403 |
|
---|
| 1404 | # generate the rule (need double evaluation here)
|
---|
| 1405 | $(eval $(def_install_src_rule))
|
---|
| 1406 |
|
---|
| 1407 | INSTARGET_$(target) += $(insdst)
|
---|
| 1408 | endef
|
---|
| 1409 |
|
---|
| 1410 |
|
---|
| 1411 | ## generate the symlink rule
|
---|
| 1412 | define def_install_symlink_rule
|
---|
| 1413 | # the install rule
|
---|
| 1414 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
| 1415 | $$(RM) -f $$@
|
---|
[380] | 1416 | $$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
[353] | 1417 | endef
|
---|
| 1418 |
|
---|
| 1419 | ## create one symlink
|
---|
| 1420 | define def_install_symlink
|
---|
| 1421 |
|
---|
| 1422 | # deal with '=>' in the source file name.
|
---|
[380] | 1423 | symdst := $(subst =>, ,$(src))
|
---|
| 1424 | symlnk := $(firstword $(symdst))
|
---|
| 1425 | symdst := $(word $(words $(symdst)),$(symdst))
|
---|
[353] | 1426 |
|
---|
| 1427 | # _INSTFUN
|
---|
[380] | 1428 | ifdef $(symlnk)_INSTFUN
|
---|
| 1429 | instfun := $(symlnk)_INSTFUN
|
---|
[353] | 1430 | else
|
---|
| 1431 | ifdef $(target)_INSTFUN
|
---|
| 1432 | instfun := $(target)_INSTFUN
|
---|
| 1433 | else
|
---|
| 1434 | instfun := _INSTALL_FILE
|
---|
| 1435 | endif
|
---|
| 1436 | endif
|
---|
| 1437 |
|
---|
| 1438 | # _INST
|
---|
[380] | 1439 | ifdef $(symlnk)_INST
|
---|
| 1440 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
[353] | 1441 | else
|
---|
| 1442 | ifdef $(target)_INST
|
---|
[380] | 1443 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
[353] | 1444 | else
|
---|
[380] | 1445 | inst := $(dir $(symlnk))
|
---|
[353] | 1446 | endif
|
---|
| 1447 | endif
|
---|
| 1448 |
|
---|
| 1449 | # calc target
|
---|
[380] | 1450 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
| 1451 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
[353] | 1452 |
|
---|
| 1453 | # generate the rule (need double evaluation here)
|
---|
| 1454 | $(eval $(def_install_symlink_rule))
|
---|
| 1455 |
|
---|
| 1456 | INSTARGET_$(target) += $(insdst)
|
---|
| 1457 | endef
|
---|
| 1458 |
|
---|
[412] | 1459 |
|
---|
[380] | 1460 | ## generate the install rule
|
---|
| 1461 | define def_install_directory_rule
|
---|
| 1462 | # the install rule
|
---|
| 1463 | $(insdst):
|
---|
| 1464 | $(INSTALL) -d \
|
---|
| 1465 | $(if $(uid),-o $(uid))\
|
---|
| 1466 | $(if $(gid),-g $(gid))\
|
---|
| 1467 | $(if $(mode),-m $(mode))\
|
---|
| 1468 | $(insdst)
|
---|
[412] | 1469 |
|
---|
| 1470 | .NOTPARALLEL: $(insdst)
|
---|
[380] | 1471 | endef
|
---|
| 1472 |
|
---|
[412] | 1473 |
|
---|
[380] | 1474 | ## create one directory
|
---|
| 1475 | define def_install_directory
|
---|
| 1476 |
|
---|
| 1477 | # _INST
|
---|
| 1478 | ifdef $(directory)_INST
|
---|
| 1479 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
| 1480 | else
|
---|
| 1481 | ifdef $(target)_INST
|
---|
| 1482 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
| 1483 | else
|
---|
| 1484 | inst := $(PATH_INS)
|
---|
| 1485 | endif
|
---|
| 1486 | endif
|
---|
| 1487 |
|
---|
| 1488 | mode := $(firstword \
|
---|
| 1489 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
| 1490 | $($(target)_$(directory)_MODE) \
|
---|
| 1491 | $($(directory)_MODE.$(bld_trg)) \
|
---|
| 1492 | $($(directory)_MODE) \
|
---|
| 1493 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 1494 | $($(target)_MODE))
|
---|
| 1495 | uid := $(firstword \
|
---|
| 1496 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
| 1497 | $($(target)_$(directory)_UID) \
|
---|
| 1498 | $($(directory)_UID.$(bld_trg)) \
|
---|
| 1499 | $($(directory)_UID) \
|
---|
| 1500 | $($(target)_UID.$(bld_trg)) \
|
---|
| 1501 | $($(target)_UID))
|
---|
| 1502 | gid := $(firstword \
|
---|
| 1503 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
| 1504 | $($(target)_$(directory)_GID) \
|
---|
| 1505 | $($(directory)_GID.$(bld_trg)) \
|
---|
| 1506 | $($(directory)_GID) \
|
---|
| 1507 | $($(target)_GID.$(bld_trg)) \
|
---|
| 1508 | $($(target)_GID))
|
---|
| 1509 |
|
---|
| 1510 | insdst := $(inst)/$(directory)/
|
---|
| 1511 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
| 1512 |
|
---|
| 1513 | # generate the rule (need double evaluation here)
|
---|
| 1514 | $(eval $(def_install_directory_rule))
|
---|
| 1515 |
|
---|
| 1516 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
| 1517 | endef
|
---|
| 1518 |
|
---|
| 1519 |
|
---|
[353] | 1520 | ## process one install target.
|
---|
| 1521 | define def_install
|
---|
| 1522 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1523 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 1524 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 1525 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 1526 |
|
---|
| 1527 | INSTARGET_$(target) :=
|
---|
[380] | 1528 | INSTARGET_DIRS_$(target) :=
|
---|
| 1529 |
|
---|
| 1530 | $(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \
|
---|
| 1531 | $(eval $(value def_install_directory)))
|
---|
| 1532 |
|
---|
[353] | 1533 | $(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
|
---|
| 1534 | $(eval $(value def_install_src)))
|
---|
| 1535 |
|
---|
| 1536 | $(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
|
---|
| 1537 | $(eval $(value def_install_symlink)))
|
---|
| 1538 |
|
---|
[380] | 1539 | _INSTALLS += $(INSTARGET_$(target)) $($(target)_GOALS)
|
---|
| 1540 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
[353] | 1541 | endef
|
---|
| 1542 |
|
---|
| 1543 | ## process all install targets
|
---|
| 1544 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)), \
|
---|
| 1545 | $(eval $(value def_install)))
|
---|
| 1546 |
|
---|
| 1547 |
|
---|
[72] | 1548 | #
|
---|
[417] | 1549 | # PACKING
|
---|
| 1550 | #
|
---|
| 1551 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET))
|
---|
| 1552 |
|
---|
| 1553 |
|
---|
| 1554 | #
|
---|
[72] | 1555 | # DOCS
|
---|
| 1556 | #
|
---|
| 1557 |
|
---|
| 1558 |
|
---|
| 1559 | #
|
---|
[353] | 1560 | # DIRECTORIES
|
---|
| 1561 | #
|
---|
| 1562 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS)))
|
---|
[380] | 1563 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
[353] | 1564 |
|
---|
[380] | 1565 |
|
---|
[353] | 1566 | define def_mkdir_rule
|
---|
| 1567 | $(directory):
|
---|
| 1568 | $(call MSG_L1,Creating directory $$@)
|
---|
| 1569 | $(MKDIR) -p $$@
|
---|
[72] | 1570 | endef
|
---|
| 1571 |
|
---|
[353] | 1572 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
[72] | 1573 |
|
---|
[183] | 1574 |
|
---|
[72] | 1575 | #
|
---|
[353] | 1576 | # NOTHING
|
---|
[72] | 1577 | #
|
---|
[353] | 1578 | do-nothing:
|
---|
| 1579 | $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
[72] | 1580 |
|
---|
[183] | 1581 |
|
---|
[75] | 1582 | #
|
---|
[353] | 1583 | # CLEAN UP
|
---|
[75] | 1584 | #
|
---|
[353] | 1585 | do-clean:
|
---|
[380] | 1586 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
[72] | 1587 |
|
---|
[98] | 1588 |
|
---|
[353] | 1589 | #
|
---|
| 1590 | # PASSES (including directory and makefile walking)
|
---|
| 1591 | #
|
---|
[221] | 1592 |
|
---|
[75] | 1593 | ## Subdir
|
---|
| 1594 | # @param $(pass) Lowercase pass name.
|
---|
| 1595 | # @param $(PASS) Uppercase pass name.
|
---|
| 1596 | # @param $(subdir) Subdirectory
|
---|
| 1597 | # @param $(tag) tag to attach to the rule name.
|
---|
| 1598 | define def_pass_subdir
|
---|
[219] | 1599 | pass_$(pass)$(tag):: $(dep)
|
---|
| 1600 | + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
[75] | 1601 | endef
|
---|
[72] | 1602 |
|
---|
[75] | 1603 | ## Submakefile
|
---|
| 1604 | # @param $(pass) Lowercase pass name.
|
---|
| 1605 | # @param $(PASS) Uppercase pass name.
|
---|
| 1606 | # @param $(makefile) Makefile.
|
---|
| 1607 | # @param $(tag) tag to attach to the rule name.
|
---|
| 1608 | define def_pass_makefile
|
---|
[219] | 1609 | pass_$(pass)$(tag):: $(dep)
|
---|
| 1610 | + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
[75] | 1611 | endef
|
---|
[73] | 1612 |
|
---|
[75] | 1613 | ## Execute a pass.
|
---|
| 1614 | # @param $(pass) Lowercase pass name.
|
---|
| 1615 | # @param $(PASS) Uppercase pass name.
|
---|
[353] | 1616 | define def_pass_old
|
---|
[183] | 1617 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
| 1618 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
| 1619 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
| 1620 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
[75] | 1621 |
|
---|
| 1622 | $(eval tag:=_before)
|
---|
[219] | 1623 | $(eval dep:=)
|
---|
[183] | 1624 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1625 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
[75] | 1626 |
|
---|
| 1627 | $(eval tag:=_after)
|
---|
[219] | 1628 | $(eval dep:=pass_$(pass)_doit)
|
---|
[183] | 1629 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1630 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 1631 |
|
---|
| 1632 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 1633 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
[353] | 1634 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
[272] | 1635 | pass_$(pass)_this: pass_$(pass)_before
|
---|
[220] | 1636 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
| 1637 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
[219] | 1638 | pass_$(pass): pass_$(pass)_after
|
---|
[75] | 1639 |
|
---|
[183] | 1640 | endef
|
---|
| 1641 |
|
---|
[353] | 1642 | define def_pass
|
---|
| 1643 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
| 1644 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
| 1645 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
| 1646 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
[183] | 1647 |
|
---|
[353] | 1648 | $(eval tag:=_before)
|
---|
| 1649 | $(eval dep:=)
|
---|
| 1650 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1651 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
[75] | 1652 |
|
---|
[353] | 1653 | $(eval tag:=_after)
|
---|
| 1654 | $(eval dep:=pass_$(pass)_doit)
|
---|
| 1655 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
| 1656 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 1657 |
|
---|
[380] | 1658 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 1659 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
| 1660 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
| 1661 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
| 1662 | pass_$(pass)_this: pass_$(pass)_before
|
---|
| 1663 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
| 1664 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
| 1665 | pass_$(pass): pass_$(pass)_after
|
---|
| 1666 | else
|
---|
[388] | 1667 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
[353] | 1668 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
| 1669 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
| 1670 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
| 1671 | pass_$(pass): \
|
---|
| 1672 | pass_$(pass)_before \
|
---|
| 1673 | pass_$(pass)_doit \
|
---|
[388] | 1674 | pass_$(pass)_after
|
---|
[353] | 1675 | endif
|
---|
[189] | 1676 |
|
---|
[353] | 1677 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
| 1678 | endef
|
---|
[75] | 1679 |
|
---|
[353] | 1680 | # Generate the defined passes.
|
---|
| 1681 | $(foreach PASS, $(PASSES), \
|
---|
| 1682 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 1683 | $(eval $(def_pass)))
|
---|
[75] | 1684 |
|
---|
[219] | 1685 | ## Pass order
|
---|
| 1686 | # @param $(pass) Current pass name.
|
---|
| 1687 | # @param $(prev_pass) The previous pass name.
|
---|
| 1688 | define def_pass_order
|
---|
[380] | 1689 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 1690 | .NOTPARALLEL: pass_$(pass)_order
|
---|
| 1691 | .PHONY: pass_$(pass)_order
|
---|
[219] | 1692 | pass_$(pass)_order: $(pass_prev)
|
---|
[353] | 1693 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
[219] | 1694 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
[353] | 1695 | else
|
---|
| 1696 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
[388] | 1697 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
[353] | 1698 | pass_$(pass)_banner:
|
---|
| 1699 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
| 1700 | pass_$(pass)_order: \
|
---|
| 1701 | $(pass_prev) \
|
---|
| 1702 | pass_$(pass)_banner \
|
---|
| 1703 | pass_$(pass)
|
---|
| 1704 | endif
|
---|
[219] | 1705 | $(eval pass_prev := pass_$(pass)_order)
|
---|
| 1706 | endef
|
---|
[183] | 1707 |
|
---|
[219] | 1708 | ## PASS: order
|
---|
| 1709 | # Use dependencies to ensure correct pass order.
|
---|
| 1710 | pass_prev :=
|
---|
[353] | 1711 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
| 1712 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 1713 | $(eval $(def_pass_order)))
|
---|
[219] | 1714 |
|
---|
[272] | 1715 |
|
---|
[75] | 1716 | #
|
---|
| 1717 | # THE MAIN RULES
|
---|
| 1718 | #
|
---|
[219] | 1719 | all_recursive: $(pass_prev)
|
---|
[75] | 1720 |
|
---|
[130] | 1721 | rebuild: clean
|
---|
[219] | 1722 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
[78] | 1723 |
|
---|
[412] | 1724 | # @todo make this a non-default pass!
|
---|
[353] | 1725 | uninstall:
|
---|
| 1726 | $(RM) -f $(_INSTALLS)
|
---|
[412] | 1727 |
|
---|
[380] | 1728 | install: pass_installs
|
---|
[78] | 1729 |
|
---|
[75] | 1730 | # misc shortcuts.
|
---|
[380] | 1731 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
[75] | 1732 | objects: $(_OBJS)
|
---|
[222] | 1733 | bldprogs: $(_BLDPROGS)
|
---|
[189] | 1734 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
[205] | 1735 | dlls: $(_DLLS)
|
---|
[219] | 1736 | programs: $(_PROGRAMS)
|
---|
[205] | 1737 | sysmods: $(_SYSMODS)
|
---|
[353] | 1738 | others: $(_OTHERS)
|
---|
[380] | 1739 | installs: $(_INSTALLS_DIRS) $(_INSTALLS)
|
---|
[75] | 1740 |
|
---|
| 1741 |
|
---|
[353] | 1742 | #
|
---|
| 1743 | # kBuild debugging stuff.
|
---|
| 1744 | #
|
---|
| 1745 | _SPACE := $(subst ., ,.)
|
---|
| 1746 | _TAB := $(subst ., ,.)
|
---|
| 1747 | define _NEWLINE
|
---|
| 1748 |
|
---|
| 1749 |
|
---|
| 1750 | endef
|
---|
| 1751 | NLTAB = $(_NEWLINE)$(TAB)
|
---|
| 1752 | show_targets:
|
---|
| 1753 | @$(foreach target, $(ALL_TARGETS),\
|
---|
| 1754 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
| 1755 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
| 1756 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
| 1757 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
[380] | 1758 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE) OBJS_ CLEAN, \
|
---|
[353] | 1759 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 1760 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
| 1761 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
| 1762 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
| 1763 | )\
|
---|
| 1764 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
| 1765 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 1766 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
| 1767 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
| 1768 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
| 1769 | ))
|
---|
| 1770 |
|
---|
| 1771 |
|
---|
| 1772 |
|
---|
| 1773 | #
|
---|
| 1774 | # Include dependency files.
|
---|
| 1775 | #
|
---|
| 1776 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
| 1777 |
|
---|
| 1778 |
|
---|
[72] | 1779 | # end-of-file-content
|
---|
[106] | 1780 | __footer_kmk__ := target
|
---|
[72] | 1781 | endif # __footer_kmk__
|
---|
[438] | 1782 |
|
---|