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