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