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