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