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