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