[72] | 1 | # $Id: footer.kmk 988 2007-05-29 03:52:30Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
[782] | 6 | # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@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
|
---|
[988] | 29 | ifdef KBUILD_PROFILE_SELF
|
---|
| 30 | _KBUILD_TS_FOOTER_START := $(nanots )
|
---|
| 31 | $(info prof: $(int-sub $(_KBUILD_TS_FOOTER_START), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_FOOTER_START), $(_KBUILD_TS_PREV)) - start of footer.kmk)
|
---|
| 32 | _KBUILD_TS_PREV := $(_KBUILD_TS_FOOTER_START)
|
---|
| 33 | endif
|
---|
[72] | 34 |
|
---|
| 35 | #
|
---|
| 36 | # Variables.
|
---|
[73] | 37 | # (Some of these need initialization before including definitions using them.)
|
---|
[72] | 38 | #
|
---|
| 39 |
|
---|
[985] | 40 | # All targets of each types.
|
---|
| 41 | _ALL_BLDPROGS := $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(BUILD_PLATFORM_CPU)) $(BLDPROGS.$(BUILD_TYPE))
|
---|
| 42 | _ALL_LIBRARIES := $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(LIBRARIES.$(BUILD_TARGET_ARCH)) $(LIBRARIES.$(BUILD_TARGET_CPU)) $(LIBRARIES.$(BUILD_TYPE))
|
---|
| 43 | _ALL_IMPORT_LIBS := $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(BUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(BUILD_TARGET_CPU)) $(IMPORT_LIBS.$(BUILD_TYPE))
|
---|
| 44 | _ALL_DLLS := $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(DLLS.$(BUILD_TARGET_ARCH)) $(DLLS.$(BUILD_TARGET_CPU)) $(DLLS.$(BUILD_TYPE))
|
---|
| 45 | _ALL_PROGRAMS := $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(PROGRAMS.$(BUILD_TARGET_ARCH)) $(PROGRAMS.$(BUILD_TARGET_CPU)) $(PROGRAMS.$(BUILD_TYPE))
|
---|
| 46 | _ALL_SYSMODS := $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(SYSMODS.$(BUILD_TARGET_ARCH)) $(SYSMODS.$(BUILD_TARGET_CPU)) $(SYSMODS.$(BUILD_TYPE))
|
---|
| 47 | _ALL_OTHERS := $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(OTHERS.$(BUILD_TARGET_ARCH)) $(OTHERS.$(BUILD_TARGET_CPU)) $(OTHERS.$(BUILD_TYPE))
|
---|
| 48 | _ALL_INSTALLS := $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(INSTALLS.$(BUILD_TARGET_ARCH)) $(INSTALLS.$(BUILD_TARGET_CPU)) $(INSTALLS.$(BUILD_TYPE))
|
---|
| 49 | _ALL_FETCHES := $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(FETCHES.$(BUILD_TARGET_ARCH)) $(FETCHES.$(BUILD_TARGET_CPU)) $(FETCHES.$(BUILD_TYPE))
|
---|
| 50 | _ALL_PATCHES := $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(PATCHES.$(BUILD_TARGET_ARCH)) $(PATCHES.$(BUILD_TARGET_CPU)) $(PATCHES.$(BUILD_TYPE))
|
---|
| 51 |
|
---|
[72] | 52 | # all targets.
|
---|
[985] | 53 | _ALL_TARGETS = \
|
---|
| 54 | $(_ALL_FETCHES) \
|
---|
| 55 | $(_ALL_PATCHES) \
|
---|
| 56 | $(_ALL_BLDPROGS) \
|
---|
| 57 | $(_ALL_LIBRARIES) \
|
---|
| 58 | $(_ALL_IMPORT_LIBS) \
|
---|
| 59 | $(_ALL_DLLS) \
|
---|
| 60 | $(_ALL_PROGRAMS) \
|
---|
| 61 | $(_ALL_SYSMODS) \
|
---|
| 62 | $(_ALL_INSTALLS) \
|
---|
| 63 | $(_ALL_OTHERS)
|
---|
[72] | 64 |
|
---|
[447] | 65 | # all $(BUILD_TARGET) targets.
|
---|
[985] | 66 | _ALL_BUILD_TARGET_TARGETS = \
|
---|
| 67 | $(_ALL_FETCHES) \
|
---|
| 68 | $(_ALL_PATCHES) \
|
---|
| 69 | $(_ALL_LIBRARIES) \
|
---|
| 70 | $(_ALL_IMPORT_LIBS) \
|
---|
| 71 | $(_ALL_DLLS) \
|
---|
| 72 | $(_ALL_PROGRAMS) \
|
---|
| 73 | $(_ALL_SYSMODS) \
|
---|
| 74 | $(_ALL_INSTALLS) \
|
---|
| 75 | $(_ALL_OTHERS)
|
---|
[447] | 76 |
|
---|
[985] | 77 | # all $(BUILD_PLATFORM) targets.
|
---|
| 78 | _ALL_BUILD_PLATFORM_TARGETS = \
|
---|
| 79 | $(_ALL_BLDPROGS)
|
---|
[447] | 80 |
|
---|
[640] | 81 | # all targets making use of srcname.
|
---|
[985] | 82 | _ALL_SRCNAME_TARGETS = \
|
---|
| 83 | $(_ALL_FETCHES) \
|
---|
| 84 | $(_ALL_PATCHES)
|
---|
[640] | 85 |
|
---|
[75] | 86 | # dependency files.
|
---|
| 87 | _DEPFILES :=
|
---|
| 88 |
|
---|
[380] | 89 | # included dependency files.
|
---|
| 90 | _DEPFILES_INCLUDED :=
|
---|
| 91 |
|
---|
| 92 |
|
---|
[75] | 93 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
| 94 | # Compiling or linking definition outputting other things that $@ and any
|
---|
| 95 | # required dependency file must add those output files to this variable.
|
---|
| 96 | _OUT_FILES :=
|
---|
| 97 |
|
---|
[353] | 98 | # Files which only requires cleaning up.
|
---|
| 99 | _CLEAN_FILES :=
|
---|
| 100 |
|
---|
[72] | 101 | # all of a type
|
---|
[219] | 102 | _OBJS :=
|
---|
[640] | 103 | _FETCHES :=
|
---|
| 104 | _DOWNLOADS:=
|
---|
| 105 | _UNPACKS :=
|
---|
| 106 | _PATCHES :=
|
---|
[688] | 107 | _UNFETCHES:=
|
---|
[222] | 108 | _BLDPROGS :=
|
---|
[219] | 109 | _LIBS :=
|
---|
| 110 | _DLLS :=
|
---|
| 111 | _PROGRAMS :=
|
---|
| 112 | _SYSMODS :=
|
---|
[353] | 113 | _INSTALLS :=
|
---|
[827] | 114 | _INSTALLS_FILES :=
|
---|
[380] | 115 | _INSTALLS_DIRS :=
|
---|
[353] | 116 | _OTHERS :=
|
---|
[417] | 117 | _PACKING :=
|
---|
[897] | 118 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS)
|
---|
[189] | 119 | _IMPORT_LIBS :=
|
---|
[72] | 120 |
|
---|
[220] | 121 | # misc
|
---|
| 122 | pass_prev :=
|
---|
| 123 |
|
---|
| 124 |
|
---|
[984] | 125 |
|
---|
[72] | 126 | #
|
---|
[984] | 127 | # Footer macros
|
---|
[73] | 128 | #
|
---|
| 129 |
|
---|
[78] | 130 | ## Figure out the tool for a target.
|
---|
[753] | 131 | # @param $1 normalized target.
|
---|
| 132 | # @param $2 tooltype.
|
---|
[222] | 133 | # @param bld_trg build target.
|
---|
[481] | 134 | # @param bld_trg_arch build target architecture.
|
---|
[79] | 135 | _TARGET_TOOL = $(strip $(firstword \
|
---|
[753] | 136 | $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 137 | $($(1)_$(2)TOOL.$(bld_trg)) \
|
---|
| 138 | $($(1)_$(2)TOOL) \
|
---|
| 139 | $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 140 | $($(1)_TOOL.$(bld_trg)) \
|
---|
| 141 | $($(1)_TOOL) \
|
---|
| 142 | $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 143 | $($(2)TOOL.$(bld_trg)) \
|
---|
| 144 | $($(2)TOOL) \
|
---|
[481] | 145 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
[222] | 146 | $(TOOL.$(bld_trg)) \
|
---|
[106] | 147 | $(TOOL) \
|
---|
[79] | 148 | ))
|
---|
[183] | 149 |
|
---|
[353] | 150 | ## Figure out the actual name of an installed file.
|
---|
| 151 | # @param $1 The file to install.
|
---|
| 152 | # @param $2 The target name.
|
---|
| 153 | # @param $3 The _INST value (can be empty).
|
---|
| 154 | # @param $4 The default directory to use when $3 is empty.
|
---|
| 155 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
---|
| 156 |
|
---|
| 157 |
|
---|
[985] | 158 | ## Inherit one template property in a non-accumulative manner.
|
---|
| 159 | # @param $(prop) Property name
|
---|
| 160 | # @param $(src) Source (parent) object.
|
---|
| 161 | # @param $(trg) Target (child) object.
|
---|
| 162 | # @remark Not all properties has all the variations, but making the correct
|
---|
| 163 | # exceptions will only complicate matters and probably not gain much speed.
|
---|
| 164 | define def_inherit_one
|
---|
| 165 | ifdef $(src)_$(prop)
|
---|
| 166 | ifndef $(trg)_$(prop)
|
---|
| 167 | $(trg)_$(prop) = $($(src)_$(prop))
|
---|
| 168 | #$ (warning dbg-inherit: $(trg)_$(prop) = $($(src)_$(prop)) )
|
---|
| 169 | endif
|
---|
| 170 | endif
|
---|
| 171 | endef # def_inherit_one
|
---|
[723] | 172 |
|
---|
[985] | 173 | ## Inherit one template property in a non-accumulative manner.
|
---|
| 174 | # @param $(prop) Property name
|
---|
| 175 | # @param $(src) Source (parent) object.
|
---|
| 176 | # @param $(trg) Target (child) object.
|
---|
| 177 | # @remark Not all properties has all the variations, but making the correct
|
---|
| 178 | # exceptions will only complicate matters and probably not gain much speed.
|
---|
| 179 | # @todo Check how/if this differs from def_inherit_one.
|
---|
| 180 | define def_inherit_one_now
|
---|
| 181 | ifdef $(src)_$(prop)
|
---|
| 182 | ifndef $(trg)_$(prop)
|
---|
| 183 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
| 184 | #$ (warning dbg-inherit-now: $(trg)_$(prop) = $($(src)_$(prop)) )
|
---|
| 185 | endif
|
---|
| 186 | endif
|
---|
| 187 | endef # def_inherit_one_now
|
---|
[185] | 188 |
|
---|
[985] | 189 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
| 190 | # @param $(prop) Property name
|
---|
| 191 | # @param $(src) Source
|
---|
| 192 | # @param $(trg) Target
|
---|
| 193 | # @remark This define relies on double evaluation
|
---|
| 194 | define def_inherit_one_deferred
|
---|
| 195 | ifdef $(src)_$(prop)
|
---|
| 196 | ifndef $(trg)_$(prop)
|
---|
| 197 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
| 198 | #$ (warning dbg-inherit-def: $(trg)_$(prop) = $($(src)_$(prop)) )
|
---|
| 199 | endif
|
---|
[185] | 200 | endif
|
---|
[985] | 201 | endef # def_inherit_one_deferred
|
---|
[185] | 202 |
|
---|
[985] | 203 | ## Generic inheritance for use with targets templates and tools.
|
---|
| 204 | # @param trg Object to consider for inheriting.
|
---|
| 205 | # @param src_prefix What to prefix the value found in EXTENDS with to get the object.
|
---|
| 206 | # @param properties List of the properties with straight expansion.
|
---|
| 207 | # @param properties_now List of the properties with immediate expansion.
|
---|
| 208 | # @param properties_deferred List of the properties with deferred expansion (e.g. function).
|
---|
| 209 | define def_inherit
|
---|
| 210 | src := $(strip $($(trg)_EXTENDS))
|
---|
| 211 | ifneq ($(src),)
|
---|
| 212 | ifndef $(trg)_EXTENDS_STATUS_
|
---|
| 213 | $(trg)_EXTENDS_STATUS_ := 0
|
---|
| 214 | src := $(src_prefix)$(src)
|
---|
[185] | 215 |
|
---|
[985] | 216 | # Recursivly process the parent (src) if it's inherting from somebody too.
|
---|
| 217 | ifdef $(src)_EXTENDS
|
---|
| 218 | ifneq ($($(src)_EXTENDS_STATUS_),42)
|
---|
| 219 | # 'foreach' will create 'trg' in a new variable context hiding
|
---|
| 220 | # out current variable. 'src' OTOH will be overwritten.
|
---|
| 221 | #$ (warning def_inherit: recursing into $(src) from $(trg))
|
---|
| 222 | $(foreach trg, $(src), $(eval $(value def_inherit)))
|
---|
| 223 | src := $(src_prefix)$(strip $($(trg)_EXTENDS))
|
---|
| 224 | endif
|
---|
| 225 | endif
|
---|
[984] | 226 |
|
---|
[985] | 227 | # Inherit the properties and mark the trg done.
|
---|
| 228 | #$ (warning def_inherit: trg=$(trg) src=$(src))
|
---|
| 229 | $(foreach prop, $(properties), $(eval $(def_inherit_one)))
|
---|
| 230 | $(foreach prop, $(properties_now), $(eval $(def_inherit_one_now)))
|
---|
| 231 | $(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_deferred)))
|
---|
| 232 | $(trg)_EXTENDS_STATUS_ := 42
|
---|
| 233 | else
|
---|
| 234 | # Check for inheritance loops.
|
---|
| 235 | ifneq ($(target)_EXTENDS_STATUS_),42)
|
---|
| 236 | $(error kBuild: Target inheritance loop! target=$(target))
|
---|
| 237 | endif
|
---|
| 238 | endif
|
---|
| 239 | endif
|
---|
| 240 | endef # def_inherit
|
---|
[984] | 241 |
|
---|
[985] | 242 |
|
---|
[984] | 243 | #
|
---|
[985] | 244 | # Determin all the templates that is being used and make
|
---|
| 245 | # sure they are present.
|
---|
[72] | 246 | #
|
---|
| 247 | _TEMPLATES := $(TEMPLATE)
|
---|
| 248 | define def_templates
|
---|
| 249 | ifdef $(target)_TEMPLATE
|
---|
[985] | 250 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
| 251 | $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them)
|
---|
| 252 | endif
|
---|
| 253 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
[72] | 254 | endif
|
---|
[985] | 255 | endef # def_templates
|
---|
[984] | 256 | $(foreach target, $(_ALL_TARGETS), $(eval $(def_templates)))
|
---|
[72] | 257 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
| 258 |
|
---|
| 259 | define def_templates_include
|
---|
| 260 | ifndef TEMPLATE_$(template)
|
---|
[985] | 261 | TEMPLATE_$(template)_INCLUDE_FILE_ := $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
|
---|
| 262 | ifneq ($(TEMPLATE_$(template)_INCLUDE_FILE_),)
|
---|
| 263 | include $(TEMPLATE_$(template)_INCLUDE_FILE_)
|
---|
| 264 | else
|
---|
| 265 | $$(error kBuild: Cannot find template '$(template)')
|
---|
| 266 | endif
|
---|
[72] | 267 | endif
|
---|
[985] | 268 | endef # def_templates_include
|
---|
[72] | 269 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
| 270 |
|
---|
[985] | 271 | #$ (warning dbg _TEMPLATES := $(_TEMPLATES))
|
---|
[74] | 272 |
|
---|
[985] | 273 |
|
---|
[72] | 274 | #
|
---|
[985] | 275 | # Determin the BLD_TRG_* keywords required for correct inherting.
|
---|
[412] | 276 | #
|
---|
[985] | 277 | # This means walking all the template and target lists in order to
|
---|
| 278 | # pick up all BLD_TRG_* attributes.
|
---|
| 279 | #
|
---|
| 280 | _BLD_TYPES := $(BUILD_TYPE)
|
---|
| 281 | _BLD_TARGETS := $(BUILD_TARGET) $(BUILD_PLATFORMS)
|
---|
| 282 | _BLD_ARCHES := $(BUILD_TARGET_ARCH) $(BUILD_PLATFORM_ARCH)
|
---|
| 283 | _BLD_CPUS := $(BUILD_TARGET_CPU) $(BUILD_PLATFORM_CPU)
|
---|
| 284 |
|
---|
| 285 | define def_collect_bld_xyz
|
---|
| 286 | ifdef ($(src)_BLD_TYPE)
|
---|
| 287 | _BLD_TYPE += $($(src)_BLD_TYPE)
|
---|
[412] | 288 | endif
|
---|
[985] | 289 | ifdef ($(src)_BLD_TRG)
|
---|
| 290 | _BLD_TARGETS += $($(src)_BLD_TRG)
|
---|
| 291 | endif
|
---|
| 292 | ifdef ($(src)_BLD_TRG_ARCH)
|
---|
| 293 | _BLD_ARCHES += $($(src)_BLD_TRG_ARCH)
|
---|
| 294 | endif
|
---|
| 295 | ifdef ($(src)_BLD_TRG_CPU)
|
---|
| 296 | _BLD_CPU += $($(src)_BLD_TRG_CPU)
|
---|
| 297 | endif
|
---|
| 298 | endef # def_collect_bld_xyz
|
---|
| 299 | $(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS)\
|
---|
| 300 | ,$(eval $(def_collect_bld_xyz)))
|
---|
[412] | 301 |
|
---|
[985] | 302 | # drop duplicate values
|
---|
| 303 | _BLD_TYPES := $(sort $(_BLD_TYPES))
|
---|
| 304 | _BLD_TARGETS := $(sort $(_BLD_TARGETS))
|
---|
| 305 | _BLD_ARCHES := $(sort $(_BLD_ARCHES))
|
---|
| 306 | _BLD_CPUS := $(sort $(_BLD_CPUS))
|
---|
[552] | 307 |
|
---|
[985] | 308 | # Construct all the possible keywords.
|
---|
| 309 | _KEYWORDS := $(_BLD_TYPES) $(_BLD_TARGETS) $(_BLD_ARCHES) $(_BLD_CPUS) \
|
---|
| 310 | $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
|
---|
| 311 | # $ (warning dbg _KEYWORDS := $(_KEYWORDS))
|
---|
[412] | 312 |
|
---|
[988] | 313 | ifdef KBUILD_PROFILE_SELF
|
---|
| 314 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 315 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done keywords)
|
---|
| 316 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 317 | endif
|
---|
[552] | 318 |
|
---|
[988] | 319 |
|
---|
[985] | 320 | #
|
---|
| 321 | # Target inheritance.
|
---|
| 322 | #
|
---|
| 323 | # This has to be done on a per target list basis as to avoid adding
|
---|
| 324 | # incorrect properties that will wast memory, time, and may confuse
|
---|
| 325 | # later strictness checks. This also has to be done *before* templates
|
---|
| 326 | # are applied to the targets. Since we're doing that part rather
|
---|
| 327 | # early on, the target inheritance feature is a bit restricted at
|
---|
| 328 | # the moment. However, this will be addressed in a little(?) while.
|
---|
| 329 | #
|
---|
[552] | 330 |
|
---|
[985] | 331 | src_prefix :=
|
---|
| 332 | ## combines the specified properties $(1) with the $(_KEYWORDS).
|
---|
| 333 | _COMB_KEY_PROP = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
|
---|
[412] | 334 |
|
---|
[985] | 335 | # Fetches.
|
---|
| 336 | properties := $(call _COMB_KEY_PROP,$(PROPS_FETCHES_SINGLE))
|
---|
| 337 | properties_now := $(call _COMB_KEY_PROP,$(PROPS_FETCHES_ACCUMULATE_R) $(PROPS_FETCHES_ACCUMULATE_L))
|
---|
| 338 | properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_FETCHES_DEFERRED))
|
---|
| 339 | $(foreach trg, $(_ALL_FETCHES),$(eval $(value def_inherit)))
|
---|
[412] | 340 |
|
---|
[985] | 341 | ## Patches. - not implemented yet.
|
---|
| 342 | #properties := $(call _COMB_KEY_PROP,$(PROPS_PATCHES_SINGLE))
|
---|
| 343 | #properties_now := $(call _COMB_KEY_PROP,$(PROPS_PATCHES_ACCUMULATE_R) $(PROPS_PATCHES_ACCUMULATE_L))
|
---|
| 344 | #properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_PATCHES_DEFERRED))
|
---|
| 345 | #$(foreach trg, $(_ALL_PATCHES),$(eval $(value def_inherit)))
|
---|
[412] | 346 |
|
---|
[985] | 347 | # Programs and build programs.
|
---|
| 348 | properties := $(call _COMB_KEY_PROP,$(PROPS_PROGRAMS_SINGLE))
|
---|
| 349 | properties_now := $(call _COMB_KEY_PROP,$(PROPS_PROGRAMS_ACCUMULATE_R) $(PROPS_PROGRAMS_ACCUMULATE_L))
|
---|
| 350 | properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_PROGRAMS_DEFERRED))
|
---|
| 351 | $(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(eval $(value def_inherit)))
|
---|
| 352 |
|
---|
| 353 | # Libraries and import libraries.
|
---|
| 354 | properties := $(call _COMB_KEY_PROP,$(PROPS_LIBRARIES_SINGLE))
|
---|
| 355 | properties_now := $(call _COMB_KEY_PROP,$(PROPS_LIBRARIES_ACCUMULATE_R) $(PROPS_LIBRARIES_ACCUMULATE_L))
|
---|
| 356 | properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_LIBRARIES_DEFERRED))
|
---|
| 357 | $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(eval $(value def_inherit)))
|
---|
| 358 |
|
---|
| 359 | # DLLs.
|
---|
| 360 | properties := $(call _COMB_KEY_PROP,$(PROPS_DLLS_SINGLE))
|
---|
| 361 | properties_now := $(call _COMB_KEY_PROP,$(PROPS_DLLS_ACCUMULATE_R) $(PROPS_DLLS_ACCUMULATE_L))
|
---|
| 362 | properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_DLLS_DEFERRED))
|
---|
| 363 | $(foreach trg, $(_ALL_DLLS),$(eval $(value def_inherit)))
|
---|
| 364 |
|
---|
| 365 | # Installs.
|
---|
| 366 | properties := $(call _COMB_KEY_PROP,$(PROPS_INSTALLS_SINGLE))
|
---|
| 367 | properties_now := $(call _COMB_KEY_PROP,$(PROPS_INSTALLS_ACCUMULATE_R) $(PROPS_INSTALLS_ACCUMULATE_L))
|
---|
| 368 | properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_INSTALLS_DEFERRED))
|
---|
| 369 | $(foreach trg, $(_ALL_INSTALLS),$(eval $(value def_inherit)))
|
---|
| 370 |
|
---|
[988] | 371 | ifdef KBUILD_PROFILE_SELF
|
---|
| 372 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 373 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done target inheritance)
|
---|
| 374 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 375 | endif
|
---|
[985] | 376 |
|
---|
[988] | 377 |
|
---|
[412] | 378 | #
|
---|
[985] | 379 | # Template Inheritance.
|
---|
| 380 | #
|
---|
| 381 | # This is much the same as with target inheritance, except we cannot
|
---|
| 382 | # restrict the properties involved since we've got a clue which target
|
---|
| 383 | # types are using them. But, we can drop the instance expansion we're
|
---|
| 384 | # doing for targets since there won't be any more changes to either the
|
---|
| 385 | # source nor the target templates beyond this exercise.
|
---|
| 386 | #
|
---|
| 387 |
|
---|
| 388 | src_prefix := TEMPLATE_
|
---|
| 389 | properties :=
|
---|
| 390 | properties_now :=
|
---|
| 391 | properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_ALL))
|
---|
| 392 | $(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(eval $(value def_inherit)))
|
---|
| 393 |
|
---|
| 394 | # done.
|
---|
| 395 | src_prefix :=
|
---|
| 396 | properties :=
|
---|
| 397 | properties_now :=
|
---|
| 398 | properties_deferred :=
|
---|
| 399 |
|
---|
[988] | 400 | ifdef KBUILD_PROFILE_SELF
|
---|
| 401 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 402 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done template inheritance)
|
---|
| 403 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 404 | endif
|
---|
[985] | 405 |
|
---|
[988] | 406 |
|
---|
[985] | 407 | #
|
---|
[72] | 408 | # Common Inheritance
|
---|
| 409 | #
|
---|
| 410 |
|
---|
[353] | 411 | ## Inherit one template property in a non-accumulative manner.
|
---|
[72] | 412 | # @param $(prop) Property name
|
---|
| 413 | # @param $(target) Target name
|
---|
[78] | 414 | # @todo fix the precedence order for some properties.
|
---|
[72] | 415 | define def_inherit_template_one
|
---|
[78] | 416 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[72] | 417 | ifndef $(target)_$(prop)
|
---|
[353] | 418 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 419 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[72] | 420 | endif
|
---|
| 421 | endif
|
---|
[447] | 422 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 423 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
| 424 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 425 | $(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[79] | 426 | endif
|
---|
| 427 | endif
|
---|
[481] | 428 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 429 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 430 | #$ (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))
|
---|
| 431 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 432 | endif
|
---|
| 433 | endif
|
---|
[455] | 434 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 435 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
| 436 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 437 | $(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 438 | endif
|
---|
| 439 | endif
|
---|
| 440 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 441 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
| 442 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 443 | $(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 444 | endif
|
---|
| 445 | endif
|
---|
[72] | 446 | endef
|
---|
| 447 |
|
---|
[353] | 448 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
| 449 | # @param 1: $(prop) Property name
|
---|
| 450 | # @param 2: $(target) Target name
|
---|
| 451 | # @todo fix the precedence order for some properties.
|
---|
| 452 | # @remark this define relies on double evaluation
|
---|
| 453 | define def_inherit_template_one_deferred
|
---|
| 454 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
| 455 | ifndef $(target)_$(prop)
|
---|
| 456 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 457 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 458 | endif
|
---|
| 459 | endif
|
---|
[447] | 460 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
| 461 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
| 462 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 463 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[353] | 464 | endif
|
---|
| 465 | endif
|
---|
[481] | 466 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 467 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 468 | #$ (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))
|
---|
| 469 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 470 | endif
|
---|
| 471 | endif
|
---|
[455] | 472 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 473 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
| 474 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 475 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 476 | endif
|
---|
| 477 | endif
|
---|
| 478 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 479 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
| 480 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 481 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 482 | endif
|
---|
| 483 | endif
|
---|
[353] | 484 | endef
|
---|
| 485 |
|
---|
[660] | 486 | ## Inherit one acculumlative template property where the 'most significant' items are at the left end.
|
---|
[78] | 487 | # @param $(prop) Property name
|
---|
| 488 | # @param $(target) Target name
|
---|
[660] | 489 | define def_inherit_template_one_accumulate_l
|
---|
[78] | 490 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[353] | 491 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
[659] | 492 | $(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
[442] | 493 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
[78] | 494 | endif
|
---|
[243] | 495 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
[353] | 496 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[659] | 497 | $(target)_$(prop).$(BUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[243] | 498 | endif
|
---|
[447] | 499 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
[659] | 500 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 501 | $(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[79] | 502 | endif
|
---|
[481] | 503 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
| 504 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
[659] | 505 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
[481] | 506 | endif
|
---|
[447] | 507 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
| 508 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
[659] | 509 | $(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
[79] | 510 | endif
|
---|
[447] | 511 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
| 512 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
[659] | 513 | $(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
[79] | 514 | endif
|
---|
[78] | 515 | endef
|
---|
| 516 |
|
---|
[660] | 517 | ## Inherit one acculumlative template property where the 'most significant' items are at the right end.
|
---|
| 518 | # @param $(prop) Property name
|
---|
| 519 | # @param $(target) Target name
|
---|
[981] | 520 | define def_inherit_template_one_accumulate_r
|
---|
[660] | 521 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
[981] | 522 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
| 523 | $(target)_$(prop) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
| 524 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
[660] | 525 | endif
|
---|
| 526 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
[981] | 527 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
| 528 | $(target)_$(prop).$(BUILD_TYPE) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
[660] | 529 | endif
|
---|
| 530 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
[981] | 531 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
| 532 | $(target)_$(prop).$(bld_trg) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
[660] | 533 | endif
|
---|
| 534 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
[981] | 535 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
| 536 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
[660] | 537 | endif
|
---|
| 538 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
[981] | 539 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
| 540 | $(target)_$(prop).$(bld_trg_cpu) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
[660] | 541 | endif
|
---|
| 542 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
[981] | 543 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
| 544 | $(target)_$(prop).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
[660] | 545 | endif
|
---|
| 546 | endef
|
---|
| 547 |
|
---|
| 548 |
|
---|
[72] | 549 | ## Inherit template properties for on target.
|
---|
| 550 | # @param $(target) Target name.
|
---|
| 551 | define def_inherit_template
|
---|
[745] | 552 | # sanity check.
|
---|
| 553 | ifdef _$(target)_ALREADY_PROCESSED
|
---|
| 554 | $(error kBuild: The target $(target) appears more than once in the target lists! Please correct the makefile(s))
|
---|
| 555 | endif
|
---|
| 556 | _$(target)_ALREADY_PROCESSED := 1
|
---|
| 557 |
|
---|
[447] | 558 | # Inherit any default template.
|
---|
| 559 | ifdef TEMPLATE
|
---|
| 560 | ifeq ($($(target)_TEMPLATE),)
|
---|
| 561 | $(eval $(target)_TEMPLATE:=$(TEMPLATE))
|
---|
| 562 | endif
|
---|
| 563 | endif
|
---|
| 564 | # Expand the template if specified.
|
---|
| 565 | ifneq ($($(target)_TEMPLATE),)
|
---|
[353] | 566 | $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
|
---|
| 567 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
---|
[981] | 568 | $(foreach prop,$(PROPS_ACCUMULATE_L),$(eval $(def_inherit_template_one_accumulate_l))) # += works fine without value
|
---|
| 569 | $(foreach prop,$(PROPS_ACCUMULATE_R),$(eval $(def_inherit_template_one_accumulate_r))) # use <= (kmk addition)
|
---|
[447] | 570 | endif
|
---|
[72] | 571 | endef
|
---|
[353] | 572 |
|
---|
[72] | 573 | # Inherit template properties
|
---|
[447] | 574 | bld_trg := $(BUILD_TARGET)
|
---|
| 575 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 576 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
| 577 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(value def_inherit_template)))
|
---|
[72] | 578 |
|
---|
[447] | 579 | bld_trg := $(BUILD_PLATFORM)
|
---|
| 580 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
| 581 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
| 582 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(value def_inherit_template)))
|
---|
[72] | 583 |
|
---|
[988] | 584 | ifdef KBUILD_PROFILE_SELF
|
---|
| 585 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 586 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done common inheritance)
|
---|
| 587 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 588 | endif
|
---|
[447] | 589 |
|
---|
[988] | 590 |
|
---|
[72] | 591 | #
|
---|
[460] | 592 | # Include tools & sdks
|
---|
[183] | 593 | #
|
---|
[985] | 594 | # The first part of this exercise is to figure out which TOOLS and SDKS
|
---|
| 595 | # that should be included.
|
---|
| 596 | #
|
---|
[592] | 597 | _TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET_ARCH)) $(TOOL.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 598 | $(TOOL.$(BUILD_PLATFORM)) $(TOOL.$(BUILD_PLATFORM_ARCH)) $(TOOL.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
| 599 | $(TOOL)
|
---|
| 600 | _SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_TARGET_ARCH)) $(SDKS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
| 601 | $(SDKS.$(BUILD_PLATFORM)) $(SDKS.$(BUILD_PLATFORM_ARCH)) $(SDKS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
| 602 | $(SDKS.$(BUILD_TYPE)) \
|
---|
| 603 | $(SDKS)
|
---|
[460] | 604 | define def_tools_sdks_target_source
|
---|
[353] | 605 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
[460] | 606 | $($(source)_$(prop).$(_bld_trg)) \
|
---|
| 607 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
---|
[481] | 608 | $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 609 | $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 610 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
---|
| 611 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
---|
[353] | 612 | $($(source)_$(prop)) \
|
---|
| 613 | $($(target)_$(source)_$(prop))))
|
---|
[460] | 614 | $(eval _SDKS += \
|
---|
| 615 | $($(source)_SDKS.$(_bld_trg)) \
|
---|
| 616 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
---|
[481] | 617 | $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 618 | $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 619 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
---|
| 620 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
---|
[592] | 621 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
| 622 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
[460] | 623 | $($(source)_SDKS) \
|
---|
| 624 | $($(target)_$(source)_SDKS))
|
---|
[985] | 625 | endef # def_tools_sdks_target_source
|
---|
[353] | 626 |
|
---|
[460] | 627 | define def_tools_sdks_target
|
---|
[985] | 628 | _bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
[460] | 629 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
| 630 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
| 631 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
| 632 |
|
---|
[353] | 633 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
[460] | 634 | $($(target)_$(prop).$(_bld_trg)) \
|
---|
| 635 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
---|
[481] | 636 | $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[353] | 637 | $($(target)_$(prop))))
|
---|
[460] | 638 | $(eval _SDKS += \
|
---|
| 639 | $($(target)_SDKS.$(_bld_trg)) \
|
---|
| 640 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
---|
[481] | 641 | $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 642 | $($(target)_SDKS))
|
---|
[353] | 643 | $(foreach source, \
|
---|
[460] | 644 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
| 645 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
[481] | 646 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
[460] | 647 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
[985] | 648 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
[353] | 649 | $($(target)_SOURCES) \
|
---|
[460] | 650 | , $(eval $(value def_tools_sdks_target_source)))
|
---|
[985] | 651 | endef # def_tools_sdks_target
|
---|
[353] | 652 |
|
---|
[640] | 653 | define def_tools_srcname_target
|
---|
[985] | 654 | _bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
[640] | 655 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
| 656 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
| 657 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
| 658 |
|
---|
| 659 | $(foreach source, $(notdir\
|
---|
| 660 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
| 661 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
| 662 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
| 663 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
[985] | 664 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
[640] | 665 | $($(target)_SOURCES) \
|
---|
| 666 | ), $(eval $(value def_tools_sdks_target_source)))
|
---|
[985] | 667 | endef # def_tools_srcname_target
|
---|
[640] | 668 |
|
---|
[460] | 669 | bld_trg := $(BUILD_TARGET)
|
---|
| 670 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 671 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
| 672 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
[640] | 673 | $(foreach target, $(_ALL_SRCNAME_TARGETS), $(eval $(value def_tools_srcname_target)))
|
---|
[72] | 674 |
|
---|
[460] | 675 | bld_trg := $(BUILD_PLATFORM)
|
---|
| 676 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
| 677 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
| 678 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
| 679 |
|
---|
| 680 |
|
---|
| 681 | # include TOOLS
|
---|
[72] | 682 | define def_tools_include
|
---|
| 683 | ifndef TOOL_$(tool)
|
---|
[985] | 684 | TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
|
---|
| 685 | ifeq ($(TOOL_$(tool)_KMK_FILE),)
|
---|
| 686 | $(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
|
---|
| 687 | endif
|
---|
| 688 | include $(TOOL_$(tool)_KMK_FILE)
|
---|
| 689 | ifndef TOOL_$(tool)
|
---|
| 690 | $(warning kBuild: TOOL_$(tool) was not by $(TOOL_$(tool)_KMK_FILE)!)
|
---|
| 691 | endif
|
---|
[72] | 692 | endif
|
---|
[985] | 693 | endef # def_tools_include
|
---|
[460] | 694 |
|
---|
| 695 | _TOOLS := $(sort $(_TOOLS))
|
---|
[353] | 696 | $(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
|
---|
[72] | 697 |
|
---|
| 698 |
|
---|
[460] | 699 | # include SDKS
|
---|
[122] | 700 | define def_sdks_include_one
|
---|
[72] | 701 | ifndef SDK_$(sdk)
|
---|
[985] | 702 | SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
|
---|
| 703 | ifeq ($(SDK_$(sdk)_KMK_FILE),)
|
---|
| 704 | $(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
|
---|
| 705 | endif
|
---|
| 706 | include $(SDK_$(sdk)_KMK_FILE)
|
---|
| 707 | ifndef SDK_$(sdk)
|
---|
| 708 | $(warning kBuild: SDK_$(sdk) was not defined by $(SDK_$(sdk)_KMK_FILE)!)
|
---|
| 709 | endif
|
---|
[72] | 710 | endif
|
---|
[985] | 711 | endef # def_sdks_include_one
|
---|
[460] | 712 |
|
---|
[859] | 713 | _SDKS := $(sort $(_SDKS))
|
---|
[353] | 714 | $(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
|
---|
[72] | 715 |
|
---|
[985] | 716 | ## @todo Execute SDKS and TOOL inhertiance.
|
---|
[380] | 717 |
|
---|
[988] | 718 | ifdef KBUILD_PROFILE_SELF
|
---|
| 719 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 720 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done tools and sdks)
|
---|
| 721 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 722 | endif
|
---|
[640] | 723 |
|
---|
[988] | 724 |
|
---|
[828] | 725 | #
|
---|
| 726 | #
|
---|
| 727 | # Target lists - Pass 1
|
---|
| 728 | #
|
---|
| 729 | # This pass is for defining variables that might be referenced in
|
---|
| 730 | # properties of other targets.
|
---|
| 731 | #
|
---|
| 732 | #
|
---|
| 733 |
|
---|
| 734 | # Don't do anything for fetch targets (yet).
|
---|
| 735 |
|
---|
| 736 | ##
|
---|
| 737 | # Link prolog for Pass 1.
|
---|
| 738 | #
|
---|
| 739 | # @param $(target) Normalized target name.
|
---|
| 740 | # @param $(EXT) EXE,DLL,SYS,LIB.
|
---|
| 741 | # @param $(EXTPRE) HOST or nothing.
|
---|
| 742 | # @param $(definst) The default _INST value.
|
---|
| 743 | # @param $(tool_prefix) LD or AR.
|
---|
| 744 | # @param $(bld_trg_base_var) TARGET or PLATFORM.
|
---|
| 745 | define def_pass1_link_common
|
---|
| 746 |
|
---|
| 747 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 748 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
| 749 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
| 750 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
| 751 |
|
---|
[889] | 752 | tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
|
---|
| 753 | name := $(firstword\
|
---|
| 754 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 755 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 756 | $($(target)_NAME.$(bld_trg))\
|
---|
| 757 | $($(target)_NAME.$(bld_type))\
|
---|
| 758 | $($(target)_NAME)\
|
---|
| 759 | $(target))
|
---|
| 760 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
[828] | 761 | ifndef PATH_$(target)
|
---|
| 762 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 763 | else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
| 764 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 765 | endif
|
---|
| 766 | ifeq ($(tool_prefix),AR) ## @todo fix this mess!
|
---|
| 767 | suff := $(firstword\
|
---|
| 768 | $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
| 769 | $($(target)_$(EXT)SUFF.$(bld_trg))\
|
---|
| 770 | $($(target)_$(EXT)SUFF)\
|
---|
| 771 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
| 772 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
|
---|
| 773 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
|
---|
| 774 | $(SUFF_LIB))
|
---|
| 775 | else
|
---|
| 776 | suff := $(firstword \
|
---|
| 777 | $($(target)_$(EXT)SUFF) \
|
---|
| 778 | $($(target)_$(EXT)SUFF) \
|
---|
| 779 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF) \
|
---|
| 780 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
| 781 | endif
|
---|
| 782 | out := $(outbase)$(suff)
|
---|
| 783 |
|
---|
| 784 | # TARGET_*
|
---|
| 785 | TARGET_$(target) := $(out)
|
---|
| 786 |
|
---|
| 787 | # INSTARGET_*
|
---|
| 788 | ifndef $(target)_NOINST
|
---|
| 789 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 790 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
| 791 |
|
---|
| 792 | else # NOINST
|
---|
| 793 | INSTARGET_$(target) :=
|
---|
| 794 | endif # NOINST
|
---|
| 795 |
|
---|
| 796 | endef
|
---|
| 797 |
|
---|
| 798 |
|
---|
| 799 | #
|
---|
| 800 | # BLDPROGS (Pass 1)
|
---|
| 801 | #
|
---|
| 802 | define def_pass1_bldprog
|
---|
| 803 | # set NOINST if not forced installation before doing the usual stuff.
|
---|
| 804 | ifndef $(target)_INST
|
---|
| 805 | $(target)_NOINST := 1
|
---|
| 806 | endif
|
---|
| 807 | $(eval $(value def_pass1_link_common))
|
---|
| 808 | endef
|
---|
| 809 |
|
---|
| 810 | EXT := EXE
|
---|
| 811 | EXTPRE := HOST
|
---|
| 812 | definst := $(PATH_BIN)
|
---|
| 813 | tool_prefix := LD
|
---|
| 814 | bld_trg_base_var := PLATFORM
|
---|
| 815 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), \
|
---|
| 816 | $(eval $(value def_pass1_bldprog)))
|
---|
| 817 |
|
---|
| 818 |
|
---|
| 819 | #
|
---|
| 820 | # LIBRARIES (Pass 1)
|
---|
| 821 | #
|
---|
| 822 | EXT := LIB
|
---|
| 823 | EXTPRE :=
|
---|
| 824 | definst := $(PATH_LIB)
|
---|
| 825 | tool_prefix := AR
|
---|
| 826 | bld_trg_base_var := TARGET
|
---|
| 827 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 828 | $(eval $(value def_pass1_link_common)))
|
---|
| 829 |
|
---|
| 830 |
|
---|
| 831 | #
|
---|
| 832 | # DLLS (Pass 1)
|
---|
| 833 | #
|
---|
| 834 | EXT := DLL
|
---|
| 835 | EXTPRE :=
|
---|
| 836 | definst := $(PATH_DLL)
|
---|
| 837 | tool_prefix := LD
|
---|
| 838 | bld_trg_base_var := TARGET
|
---|
| 839 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 840 | $(eval $(value def_pass1_link_common)))
|
---|
| 841 |
|
---|
| 842 |
|
---|
| 843 | #
|
---|
| 844 | # IMPORT LIBRARIES (Pass 1)
|
---|
| 845 | #
|
---|
| 846 | # - On OS/2 and windows these are libraries.
|
---|
| 847 | # - On other platforms they are fake DLLs.
|
---|
| 848 | #
|
---|
| 849 | ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
|
---|
| 850 | EXT := LIB
|
---|
| 851 | EXTPRE :=
|
---|
| 852 | definst := $(PATH_LIB)
|
---|
| 853 | tool_prefix := AR
|
---|
| 854 | bld_trg_base_var := TARGET
|
---|
| 855 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 856 | $(eval $(value def_pass1_lib)))
|
---|
| 857 | else
|
---|
| 858 | EXT := DLL
|
---|
| 859 | EXTPRE :=
|
---|
| 860 | definst := $(PATH_DLL)
|
---|
| 861 | tool_prefix := LD
|
---|
| 862 | bld_trg_base_var := TARGET
|
---|
| 863 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 864 | $(eval $(value def_pass1_link_common)))
|
---|
| 865 | endif
|
---|
| 866 |
|
---|
| 867 |
|
---|
| 868 | #
|
---|
| 869 | # PROGRAMS (Pass 1)
|
---|
| 870 | #
|
---|
| 871 | EXT := EXE
|
---|
| 872 | EXTPRE :=
|
---|
| 873 | definst := $(PATH_BIN)
|
---|
| 874 | tool_prefix := LD
|
---|
| 875 | bld_trg_base_var := TARGET
|
---|
| 876 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 877 | $(eval $(value def_pass1_link_common)))
|
---|
| 878 |
|
---|
| 879 |
|
---|
| 880 | #
|
---|
| 881 | # SYSMODS (Pass 1)
|
---|
| 882 | #
|
---|
| 883 | EXT := SYS
|
---|
| 884 | EXTPRE :=
|
---|
| 885 | definst := $(PATH_SYS)
|
---|
| 886 | tool_prefix := LD
|
---|
| 887 | bld_trg_base_var := TARGET
|
---|
| 888 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 889 | $(eval $(value def_pass1_link_common)))
|
---|
| 890 |
|
---|
| 891 |
|
---|
| 892 | #
|
---|
| 893 | # INSTALLS (Pass 1)
|
---|
| 894 | # Note! INSTARGET_* for INSTALLS aren't available until later.
|
---|
| 895 | #
|
---|
| 896 | define def_pass1_install
|
---|
[985] | 897 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 898 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
[828] | 899 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 900 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 901 | # TARGET_*
|
---|
| 902 | TARGET_$(target) := $(PATH_TARGET)/$(target).ins
|
---|
| 903 | # INSTARGET_ later.
|
---|
| 904 | endef
|
---|
| 905 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 906 | $(eval $(value def_pass1_install)))
|
---|
| 907 |
|
---|
[988] | 908 | ifdef KBUILD_PROFILE_SELF
|
---|
| 909 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 910 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done pass 1)
|
---|
| 911 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 912 | endif
|
---|
[828] | 913 |
|
---|
| 914 |
|
---|
| 915 |
|
---|
[988] | 916 |
|
---|
[828] | 917 | #
|
---|
| 918 | #
|
---|
| 919 | # Target lists - Pass 2
|
---|
| 920 | #
|
---|
| 921 | #
|
---|
| 922 |
|
---|
| 923 |
|
---|
[688] | 924 | ## @page pg_fetches Fetching Tools, Sources and Similar.
|
---|
[73] | 925 | #
|
---|
[688] | 926 | # The targets listed in the the FETCHES target list have the following attributes:
|
---|
| 927 | # SOURCES
|
---|
| 928 | # INST
|
---|
| 929 | # FETCHTOOL
|
---|
| 930 | # FETCHFLAGS
|
---|
| 931 | # FETCHDIR
|
---|
| 932 | # UNPACKTOOL
|
---|
| 933 | # UNPACKFLAGS
|
---|
[640] | 934 | #
|
---|
[719] | 935 | # As usual the target name is an alias for 'creating' the target. Other
|
---|
[688] | 936 | # aliases are:
|
---|
| 937 | # pass_fetches
|
---|
| 938 | # fetch
|
---|
| 939 | # unfetch
|
---|
| 940 | # download
|
---|
| 941 | # unpack
|
---|
| 942 | #
|
---|
| 943 | # @remark
|
---|
| 944 | #
|
---|
| 945 | # This is a little bit complex because we must guarantee that if a source file
|
---|
[719] | 946 | # changes only sligtly we must refetch it and to a proper unpacking of it. It
|
---|
| 947 | # is also a desire that fetched archives and unpacked files can be deleted to
|
---|
[688] | 948 | # save space.
|
---|
| 949 | #
|
---|
[719] | 950 | # Thus, we must be able to cleanup what we've unpacked should any of the
|
---|
[688] | 951 | # sources be removed. We do this by maintaining a file listing the files
|
---|
| 952 | # and directories that was unpacked. This operation is named 'unfetch'.
|
---|
| 953 | #
|
---|
[719] | 954 | # We make use of the SIZE and MD5 attributes for each of the sources to
|
---|
[689] | 955 | # create a digest that is stored in the primary target file. Subsequent
|
---|
| 956 | # runswill compare their digest with it to decide if a refetch is required.
|
---|
[719] | 957 | # When a refetch is found necessary, an 'unfetch' is performed first to
|
---|
[689] | 958 | # clean out old files and directores. Note even changes in source order
|
---|
[719] | 959 | # will cause a refetch due to the way the digest is constructed and
|
---|
[689] | 960 | # evaluated.
|
---|
[688] | 961 | #
|
---|
| 962 | # By not depending directly on the archives (nor on any unpacked files)
|
---|
| 963 | # but on a goal made up from the archive name, size and md5, we allow
|
---|
| 964 | # the user to delete the archives. Naturally, this means we'll have to
|
---|
| 965 | # check and fetch missing archives before attempting to unpack them.
|
---|
[689] | 966 | #
|
---|
| 967 | # @remark
|
---|
| 968 | #
|
---|
[719] | 969 | # This feature will *NOT* work correctly with vanilla GNU make becuase
|
---|
[689] | 970 | # it makes use of includedep to avoid too many unnecessary files.
|
---|
[719] | 971 | #
|
---|
[689] | 972 | # @todo
|
---|
[688] | 973 | # 1. Port md5sum or some equivalent tool and include it in kBuild.
|
---|
| 974 | # 2. Download corruption / continuation.
|
---|
| 975 | # 3. It's quite possible that there is one too many indirect dependency now...
|
---|
| 976 | #
|
---|
| 977 |
|
---|
| 978 | ## @todo move this!
|
---|
[640] | 979 | MD5SUM := md5sum
|
---|
| 980 |
|
---|
| 981 | ## generates the fetch rule
|
---|
| 982 | define def_fetch_src_fetch_rule
|
---|
| 983 | # Indirect goal for downloading something.
|
---|
[682] | 984 | .PRECIOUS: $(out)
|
---|
[640] | 985 | $(out) $($(target)_$(srcname)_FETCH_OUTPUT_): | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
[776] | 986 | $$(call MSG_FETCH_DL,$(target),$(source),$(out))
|
---|
[696] | 987 | @## @todo do fancy stuff like download continuation.
|
---|
| 988 | $$(QUIET)$$(RM) -f $(out) $(out).md5
|
---|
[640] | 989 | $($(target)_$(srcname)_FETCH_CMDS_)
|
---|
[696] | 990 | $$(QUIET2)$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
|
---|
| 991 | $$(QUIET)$(if $(md5),$$(MD5SUM) -c $(out).md5)
|
---|
[640] | 992 |
|
---|
| 993 |
|
---|
[682] | 994 |
|
---|
[640] | 995 | # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
|
---|
| 996 | $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
[776] | 997 | $$(call MSG_FETCH_CHK,$(target),$(source),$(out))
|
---|
[696] | 998 | $$(QUIET)$$(RM) -f $$@ $(out).md5
|
---|
[640] | 999 | @# creates the .md5 we pass to md5sum.
|
---|
[696] | 1000 | $$(QUIET2)$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
|
---|
[688] | 1001 | @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
|
---|
[696] | 1002 | @## @todo do fancy stuff like download continuation.
|
---|
| 1003 | $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM) -c $(out).md5, true) ) \
|
---|
| 1004 | || ( $$(RM_EXT) -f $(out) \
|
---|
| 1005 | && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory )
|
---|
| 1006 | $$(QUIET2)$$(APPEND) $$@
|
---|
[640] | 1007 |
|
---|
[719] | 1008 | _TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
|
---|
[640] | 1009 |
|
---|
[688] | 1010 | # Just a little precaution.
|
---|
| 1011 | .NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
|
---|
| 1012 |
|
---|
[640] | 1013 | endef
|
---|
| 1014 |
|
---|
| 1015 | ## generates the unpack rule
|
---|
| 1016 | define def_fetch_src_unpack_rule
|
---|
| 1017 | # This is the unpack rule. it has an order-only dependency on the download check.
|
---|
| 1018 | $(out) $($(target)_$(srcname)_UNPACK_OUTPUT_): $($(target)_$(srcname)_UNPACK_DEPEND_) \
|
---|
| 1019 | | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size)
|
---|
[776] | 1020 | $$(call MSG_FETCH_UP,$(target),$(archive),$(inst))
|
---|
[696] | 1021 | $$(QUIET)$$(RM) -f $(out)
|
---|
[688] | 1022 | @# if the source archive doesn't exist fetch it (can have been deleted to save space).
|
---|
[696] | 1023 | $$(QUIET)test -f $(archive) \
|
---|
| 1024 | || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
|
---|
| 1025 | && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory )
|
---|
[640] | 1026 | $($(target)_$(srcname)_UNPACK_CMDS_)
|
---|
[696] | 1027 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
|
---|
| 1028 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(out))
|
---|
[640] | 1029 |
|
---|
| 1030 | $(eval _TARGET_$(target)_UNPACKED += $(out))
|
---|
| 1031 | _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
|
---|
| 1032 |
|
---|
[688] | 1033 | .NOTPARALLEL: $(out)
|
---|
| 1034 |
|
---|
[719] | 1035 | endef
|
---|
[640] | 1036 |
|
---|
| 1037 | ## Processes a fetch source
|
---|
| 1038 | #
|
---|
| 1039 | define def_fetch_src
|
---|
| 1040 | #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
|
---|
| 1041 |
|
---|
| 1042 | # common
|
---|
| 1043 | srcname := $(notdir $(source))
|
---|
| 1044 | inst := $(firstword \
|
---|
| 1045 | $($(target)_$(source)_INST)\
|
---|
| 1046 | $($(target)_$(srcname)_INST)\
|
---|
| 1047 | $($(source)_INST)\
|
---|
| 1048 | $($(srcname)_INST)\
|
---|
| 1049 | $($(target)_INST)\
|
---|
| 1050 | )
|
---|
| 1051 | ifneq ($(patsubst %/,ok,$(inst)),ok)
|
---|
| 1052 | $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
|
---|
| 1053 | endif
|
---|
| 1054 | INSTARGET_$(target)_$(srcname) := $(inst)
|
---|
| 1055 | fetchdir := $(firstword \
|
---|
| 1056 | $($(target)_$(source)_FETCHDIR)\
|
---|
| 1057 | $($(target)_$(srcname)_FETCHDIR)\
|
---|
| 1058 | $($(source)_FETCHDIR)\
|
---|
| 1059 | $($(srcname)_FETCHDIR)\
|
---|
| 1060 | $($(target)_FETCHDIR)\
|
---|
| 1061 | $(FETCHDIR)\
|
---|
| 1062 | $(PATH_TARGET)\
|
---|
| 1063 | )
|
---|
| 1064 | deps := \
|
---|
| 1065 | $($(target)_$(source)_DEPS)\
|
---|
| 1066 | $($(target)_$(srcname)_DEPS)\
|
---|
| 1067 | $($(source)_DEPS)\
|
---|
| 1068 | $($(srcname)_DEPS)\
|
---|
| 1069 | $($(target)_DEPS)
|
---|
[827] | 1070 | orderdeps := \
|
---|
| 1071 | $($(target)_$(source)_ORDERDEPS)\
|
---|
| 1072 | $($(target)_$(srcname)_ORDERDEPS)\
|
---|
| 1073 | $($(source)_ORDERDEPS)\
|
---|
| 1074 | $($(srcname)_ORDERDEPS)\
|
---|
| 1075 | $($(target)_ORDERDEPS)
|
---|
[640] | 1076 | md5 := $(firstword \
|
---|
| 1077 | $($(target)_$(source)_MD5)\
|
---|
| 1078 | $($(target)_$(srcname)_MD5)\
|
---|
| 1079 | $($(source)_MD5)\
|
---|
| 1080 | $($(srcname)_MD5)\
|
---|
| 1081 | $($(target)_MD5)\
|
---|
| 1082 | )
|
---|
| 1083 | size := $(firstword \
|
---|
| 1084 | $($(target)_$(source)_SIZE)\
|
---|
| 1085 | $($(target)_$(srcname)_SIZE)\
|
---|
| 1086 | $($(source)_SIZE)\
|
---|
| 1087 | $($(srcname)_SIZE)\
|
---|
| 1088 | $($(target)_SIZE)\
|
---|
| 1089 | )
|
---|
| 1090 | dep := # not legal for fetch and unpack tools
|
---|
| 1091 |
|
---|
| 1092 |
|
---|
| 1093 | #
|
---|
| 1094 | # The fetching.
|
---|
| 1095 | #
|
---|
| 1096 | out := $(fetchdir)/$(srcname)
|
---|
| 1097 | archive := $(out)
|
---|
| 1098 | TARGET_$(target)_$(srcname) := $(out)
|
---|
| 1099 | dirdep := $(call DIRDEP,$(fetchdir))
|
---|
| 1100 | tool := $(firstword \
|
---|
| 1101 | $($(target)_$(source)_FETCHTOOL)\
|
---|
| 1102 | $($(target)_$(srcname)_FETCHTOOL)\
|
---|
| 1103 | $($(target)_$(source)_TOOL)\
|
---|
| 1104 | $($(target)_$(srcname)_TOOL)\
|
---|
| 1105 | $($(source)_FETCHTOOL)\
|
---|
| 1106 | $($(srcname)_FETCHTOOL)\
|
---|
| 1107 | $($(source)_TOOL)\
|
---|
| 1108 | $($(srcname)_TOOL)\
|
---|
| 1109 | $($(target)_FETCHTOOL)\
|
---|
| 1110 | $($(target)_TOOL)\
|
---|
| 1111 | )
|
---|
| 1112 | flags :=\
|
---|
| 1113 | $(TOOL_$(tool)_FETCHFLAGS)\
|
---|
| 1114 | $(FETCHFLAGS)\
|
---|
| 1115 | $($(target)_FETCHFLAGS)\
|
---|
| 1116 | $($(srcname)_FETCHFLAGS)\
|
---|
| 1117 | $($(source)_FETCHFLAGS)\
|
---|
| 1118 | $($(target)_$(srcname)_FETCHFLAGS)\
|
---|
| 1119 | $($(target)_$(source)_FETCHFLAGS)
|
---|
| 1120 |
|
---|
| 1121 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
|
---|
| 1122 |
|
---|
| 1123 | ifndef TOOL_$(tool)_FETCH_CMDS
|
---|
| 1124 | $(warning kBuild: tools: \
|
---|
| 1125 | 1 $($(target)_$(source)_FETCHTOOL)\
|
---|
| 1126 | 2 $($(target)_$(srcname)_FETCHTOOL)\
|
---|
| 1127 | 3 $($(target)_$(source)_TOOL)\
|
---|
| 1128 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
| 1129 | 5 $($(source)_FETCHTOOL)\
|
---|
| 1130 | 6 $($(srcname)_FETCHTOOL)\
|
---|
| 1131 | 7 $($(source)_TOOL)\
|
---|
| 1132 | 8 $($(srcname)_TOOL)\
|
---|
| 1133 | 9 $($(target)_FETCHTOOL)\
|
---|
| 1134 | 10 $($(target)_TOOL) )
|
---|
| 1135 | $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
|
---|
| 1136 | endif
|
---|
| 1137 |
|
---|
| 1138 | # call the tool
|
---|
| 1139 | $(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS)
|
---|
| 1140 | $(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT)
|
---|
| 1141 | $(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
|
---|
[827] | 1142 | $(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps)
|
---|
[640] | 1143 |
|
---|
| 1144 | # generate the fetch rule.
|
---|
| 1145 | $(eval $(def_fetch_src_fetch_rule))
|
---|
| 1146 |
|
---|
| 1147 |
|
---|
| 1148 | #
|
---|
| 1149 | # The unpacking / installing.
|
---|
| 1150 | #
|
---|
| 1151 | out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
|
---|
| 1152 | dirdep := $(call DIRDEP,$(inst))
|
---|
| 1153 | tool := $(firstword \
|
---|
| 1154 | $($(target)_$(source)_UNPACKTOOL)\
|
---|
| 1155 | $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
| 1156 | $($(target)_$(source)_TOOL)\
|
---|
| 1157 | $($(target)_$(srcname)_TOOL)\
|
---|
| 1158 | $($(source)_UNPACKTOOL)\
|
---|
| 1159 | $($(srcname)_UNPACKTOOL)\
|
---|
| 1160 | $($(source)_TOOL)\
|
---|
| 1161 | $($(srcname)_TOOL)\
|
---|
| 1162 | $($(target)_UNPACKTOOL)\
|
---|
| 1163 | $($(target)_TOOL) \
|
---|
| 1164 | )
|
---|
| 1165 | ifeq ($(tool),)
|
---|
| 1166 | tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
|
---|
| 1167 | $(eval $(value def_tools_include))
|
---|
| 1168 | endif
|
---|
| 1169 | flags :=\
|
---|
| 1170 | $(TOOL_$(tool)_UNPACKFLAGS)\
|
---|
| 1171 | $(UNPACKFLAGS)\
|
---|
| 1172 | $($(target)_UNPACKFLAGS)\
|
---|
| 1173 | $($(srcname)_UNPACKFLAGS)\
|
---|
| 1174 | $($(source)_UNPACKFLAGS)\
|
---|
| 1175 | $($(target)_$(srcname)_UNPACKFLAGS)\
|
---|
| 1176 | $($(target)_$(source)_UNPACKFLAGS)
|
---|
| 1177 |
|
---|
| 1178 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
|
---|
| 1179 | ifndef TOOL_$(tool)_UNPACK_CMDS
|
---|
| 1180 | $(warning kBuild: tools: \
|
---|
| 1181 | 1 $($(target)_$(source)_UNPACKTOOL)\
|
---|
| 1182 | 2 $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
| 1183 | 3 $($(target)_$(source)_TOOL)\
|
---|
| 1184 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
| 1185 | 5 $($(source)_UNPACKTOOL)\
|
---|
| 1186 | 6 $($(srcname)_UNPACKTOOL)\
|
---|
| 1187 | 7 $($(source)_TOOL)\
|
---|
| 1188 | 8 $($(srcname)_TOOL)\
|
---|
| 1189 | 9 $($(target)_UNPACKTOOL)\
|
---|
| 1190 | 10 $($(target)_TOOL) \
|
---|
| 1191 | 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
|
---|
| 1192 | )
|
---|
| 1193 | $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
|
---|
| 1194 | endif
|
---|
| 1195 |
|
---|
| 1196 | # call the tool
|
---|
| 1197 | $(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS)
|
---|
| 1198 | $(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT)
|
---|
| 1199 | $(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
|
---|
[827] | 1200 | $(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps)
|
---|
[640] | 1201 |
|
---|
| 1202 | # generate the fetch rule.
|
---|
| 1203 | $(eval $(def_fetch_src_unpack_rule))
|
---|
| 1204 |
|
---|
| 1205 | _DIRS += $(inst) $(fetchdir)
|
---|
| 1206 |
|
---|
| 1207 | endef
|
---|
| 1208 |
|
---|
| 1209 |
|
---|
| 1210 | ##
|
---|
| 1211 | # Define the target level rules for a fetch.
|
---|
| 1212 | # @param target
|
---|
| 1213 | # @param out
|
---|
| 1214 | # @param inst
|
---|
[688] | 1215 | # @param _TARGET_$(target)_UNPACKED
|
---|
| 1216 | # @param _TARGET_$(target)_DIGEST
|
---|
[640] | 1217 | # @param bld_trg
|
---|
| 1218 | # @param bld_trg_arch
|
---|
| 1219 | define def_fetch_rules
|
---|
| 1220 |
|
---|
[689] | 1221 | $(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
|
---|
[776] | 1222 | $$(call MSG_FETCH_OK,$(target))
|
---|
[696] | 1223 | $$(QUIET)$$(RM) -f $$@ $$@.tmp
|
---|
| 1224 | $$(QUIET2)$$(APPEND) $$@.tmp "$(notdir $(out))"
|
---|
| 1225 | $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
|
---|
| 1226 | $$(QUIET)$$(MV) -f $$@.tmp $$@
|
---|
[640] | 1227 |
|
---|
| 1228 | $(out)_unfetched:
|
---|
[776] | 1229 | $$(call MSG_UNFETCH,$(target))
|
---|
[696] | 1230 | $$(QUIET)$$(RM) -f $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
|
---|
| 1231 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@) \
|
---|
[689] | 1232 | $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
|
---|
[696] | 1233 | $$(QUIET)$$(RM) -f $(out).lst $(out)
|
---|
| 1234 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@)
|
---|
[640] | 1235 |
|
---|
[689] | 1236 | $(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
|
---|
[696] | 1237 | $$(QUIET)$$(RM) -f $$@
|
---|
[776] | 1238 | $$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(wildcard $(out).lst)\
|
---|
| 1239 | ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target)))
|
---|
[696] | 1240 | $$(QUIET)$$(if $$(wildcard $(out).lst ),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched)
|
---|
[701] | 1241 | $$(QUIET)$$(if $$(_TARGET_$(target)_DIGEST),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out).lst,$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@))
|
---|
[696] | 1242 | $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
|
---|
[760] | 1243 |
|
---|
[689] | 1244 | .NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
|
---|
[688] | 1245 |
|
---|
[640] | 1246 | endef
|
---|
| 1247 |
|
---|
| 1248 |
|
---|
| 1249 | ##
|
---|
| 1250 | # Deal with one fetch target.
|
---|
| 1251 | # @param target
|
---|
| 1252 | # @param bld_trg
|
---|
| 1253 | # @param bld_trg_arch
|
---|
| 1254 | define def_fetch
|
---|
| 1255 | # common
|
---|
| 1256 | INSTARGET_$(target) := $($(target)_INST)
|
---|
| 1257 | ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
|
---|
[679] | 1258 | $(error kBuild: Bad or missing INST property for target '$(target)'. \
|
---|
| 1259 | $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
|
---|
[640] | 1260 | endif
|
---|
| 1261 | _TARGET_$(target)_FETCHED :=
|
---|
| 1262 | _TARGET_$(target)_UNPACKED :=
|
---|
| 1263 | _TARGET_$(target)_DIGEST :=
|
---|
| 1264 |
|
---|
| 1265 | # The 'sources'.
|
---|
| 1266 | #$ (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)))
|
---|
| 1267 | $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
| 1268 | $(eval $(value def_fetch_src)))
|
---|
| 1269 |
|
---|
| 1270 | # The target.
|
---|
| 1271 | inst := $(INSTARGET_$(target))
|
---|
| 1272 | out := $(inst)_kBuild_fetch_$(target)
|
---|
| 1273 |
|
---|
[689] | 1274 | $(eval includedep $(out))
|
---|
[690] | 1275 |
|
---|
[640] | 1276 | $(eval $(def_fetch_rules))
|
---|
| 1277 |
|
---|
[690] | 1278 | # Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
|
---|
[749] | 1279 | $(target): $(out)
|
---|
| 1280 | $(target)_unfetch: $(out)_unfetched
|
---|
[690] | 1281 |
|
---|
[689] | 1282 | _FETCHES += $(out)
|
---|
[640] | 1283 | _DOWNLOADS += $(_TARGET_$(target)_FETCHED)
|
---|
| 1284 | _UNPACKS += $(_TARGET_$(target)_UNPACKED)
|
---|
| 1285 | _UNFETCHES += $(out)_unfetched
|
---|
| 1286 | _DIRS += $(inst)
|
---|
| 1287 |
|
---|
| 1288 | endef
|
---|
| 1289 |
|
---|
| 1290 | # Walk the FETCH target lists.
|
---|
| 1291 | bld_trg := $(BUILD_TARGET)
|
---|
| 1292 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
| 1293 | $(foreach target, $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 1294 | $(eval $(value def_fetch)))
|
---|
| 1295 |
|
---|
| 1296 | # some aliases.
|
---|
| 1297 | download: $(_DOWNLOADS)
|
---|
[688] | 1298 | unpack: $(_UNPACKS)
|
---|
| 1299 | fetch: $(_FETCHES)
|
---|
| 1300 | unfetch: $(_UNFETCHES)
|
---|
[640] | 1301 |
|
---|
[988] | 1302 | ifdef KBUILD_PROFILE_SELF
|
---|
| 1303 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 1304 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done fetching targets)
|
---|
| 1305 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 1306 | endif
|
---|
[640] | 1307 |
|
---|
| 1308 |
|
---|
[988] | 1309 |
|
---|
[640] | 1310 | ##
|
---|
| 1311 | ## Patching.
|
---|
| 1312 | ##
|
---|
| 1313 | ##
|
---|
[688] | 1314 | #define def_patch_src
|
---|
[640] | 1315 | #
|
---|
| 1316 | #endef
|
---|
| 1317 | #
|
---|
| 1318 | #
|
---|
| 1319 | ## Deal with one patch target.
|
---|
| 1320 | #define def_patch
|
---|
| 1321 | #
|
---|
| 1322 | #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
[688] | 1323 | # $(eval $(value def_patch_src)))
|
---|
[640] | 1324 | #
|
---|
[719] | 1325 | #_PATCHES +=
|
---|
[640] | 1326 | #endef
|
---|
| 1327 | #
|
---|
| 1328 | #$(foreach target, $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
| 1329 | # $(eval $(value def_patch)))
|
---|
| 1330 | #
|
---|
| 1331 |
|
---|
| 1332 |
|
---|
| 1333 | #
|
---|
[73] | 1334 | # Object processing.
|
---|
| 1335 | #
|
---|
[72] | 1336 |
|
---|
[380] | 1337 | ## wrapper the compile command dependency check.
|
---|
| 1338 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
[741] | 1339 | _DEP_COMPILE_CMDS = $(comp-cmds $(target)_$(source)_CMDS_PREV_,$(target)_$(source)_CMDS_,FORCE)
|
---|
[380] | 1340 | else
|
---|
[730] | 1341 | _DEP_COMPILE_CMDS =
|
---|
[380] | 1342 | endif
|
---|
| 1343 |
|
---|
[749] | 1344 | ## Generates the rules for building a specific object, and the aliases
|
---|
[380] | 1345 | # for building a source file.
|
---|
[353] | 1346 | # @param $(obj) The object file.
|
---|
[380] | 1347 | define def_target_source_rule
|
---|
[984] | 1348 | $(obj) + $($(target)_$(source)_OUTPUT_) : \
|
---|
[380] | 1349 | $($(target)_$(source)_DEPEND_) \
|
---|
| 1350 | $(_DEP_COMPILE_CMDS) \
|
---|
| 1351 | | \
|
---|
| 1352 | $($(target)_$(source)_DEPORD_)
|
---|
[776] | 1353 | $$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
---|
[696] | 1354 | $$(QUIET)$$(RM) -f $(dep) $(obj) $($(target)_$(source)_OUTPUT_)
|
---|
[412] | 1355 |
|
---|
[380] | 1356 | $($(target)_$(source)_CMDS_)
|
---|
| 1357 |
|
---|
| 1358 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
[696] | 1359 | $$(QUIET2)$$(APPEND) "$(dep)"
|
---|
| 1360 | $$(QUIET2)$$(APPEND) "$(dep)" 'define $(target)_$(source)_CMDS_PREV_'
|
---|
[770] | 1361 | ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
|
---|
| 1362 | $$(QUIET2)$$(APPEND) -v "$(dep)" '$(target)_$(source)_CMDS_'
|
---|
| 1363 | else
|
---|
[696] | 1364 | $$(QUIET2)$$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_$(source)_CMDS_))'
|
---|
[770] | 1365 | endif
|
---|
[696] | 1366 | $$(QUIET2)$$(APPEND) "$(dep)" 'endef'
|
---|
[412] | 1367 | endif
|
---|
[380] | 1368 |
|
---|
[749] | 1369 | $(basename $(notdir $(obj))).o: $(obj)
|
---|
| 1370 | $(basename $(notdir $(obj))).obj: $(obj)
|
---|
[353] | 1371 | endef
|
---|
[205] | 1372 |
|
---|
[353] | 1373 |
|
---|
[380] | 1374 | ## wrapper the link command dependency check.
|
---|
| 1375 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
[741] | 1376 | _DEP_LINK_CMDS = $(comp-cmds $(target)_CMDS_PREV_,$(target)_CMDS_,FORCE)
|
---|
[380] | 1377 | else
|
---|
[730] | 1378 | _DEP_LINK_CMDS =
|
---|
[380] | 1379 | endif
|
---|
| 1380 |
|
---|
| 1381 | ## Generate the link rule for a target.
|
---|
| 1382 | # @param $(target) The normalized target name.
|
---|
| 1383 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
| 1384 | # @param $(dep) The name of the dependency file.
|
---|
| 1385 | # @param $(out)
|
---|
| 1386 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
| 1387 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
| 1388 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
| 1389 | # @param $($(target)_CMDS_) The link commands.
|
---|
| 1390 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
| 1391 | define def_link_rule
|
---|
[984] | 1392 | $(out) + $($(target)_OUTPUT_) : \
|
---|
[380] | 1393 | $($(target)_DEPEND_) \
|
---|
| 1394 | $(_DEP_LINK_CMDS) \
|
---|
| 1395 | | \
|
---|
| 1396 | $($(target)_DEPORD_)
|
---|
[776] | 1397 | $$(call MSG_LINK,$(target),$$@,$(tool_do))
|
---|
[696] | 1398 | $$(QUIET)$$(RM) -f $(dep) $(out) $($(target)_OUTPUT_)
|
---|
[412] | 1399 |
|
---|
[380] | 1400 | $($(target)_CMDS_)
|
---|
| 1401 |
|
---|
[524] | 1402 | ifndef NO_LINK_CMDS_DEPS
|
---|
[696] | 1403 | $$(QUIET2)$$(APPEND) "$(dep)" 'define $(target)_CMDS_PREV_'
|
---|
[770] | 1404 | ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
|
---|
| 1405 | $$(QUIET2)$$(APPEND) -v "$(dep)" '$(target)_CMDS_'
|
---|
| 1406 | else
|
---|
[696] | 1407 | $$(QUIET2)$$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_CMDS_))'
|
---|
[770] | 1408 | endif
|
---|
[696] | 1409 | $$(QUIET2)$$(APPEND) "$(dep)" 'endef'
|
---|
[412] | 1410 | endif
|
---|
[380] | 1411 |
|
---|
[749] | 1412 | $(basename $(notdir $(out))): $(out)
|
---|
[719] | 1413 |
|
---|
[380] | 1414 | endef
|
---|
| 1415 |
|
---|
| 1416 |
|
---|
| 1417 | ## Generate the link & lib install rule
|
---|
| 1418 | # @param $(target) Normalized target name.
|
---|
| 1419 | # @param $(out) The build target.
|
---|
| 1420 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
| 1421 | # @param $(mode) The file mode (optional)
|
---|
| 1422 | define def_link_install_rule
|
---|
| 1423 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
[776] | 1424 | $$(call MSG_INST_TRG,$(target),$(out),$$@)
|
---|
[696] | 1425 | $$(QUIET)$$(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
[719] | 1426 |
|
---|
| 1427 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
[749] | 1428 | $(basename $(notdir $(out))): $(INSTARGET_$(target))
|
---|
[719] | 1429 | endif
|
---|
[380] | 1430 | endef
|
---|
| 1431 |
|
---|
| 1432 |
|
---|
[73] | 1433 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
| 1434 | # @param $(target) Normalized target name.
|
---|
| 1435 | # @param $(source) Source file name.
|
---|
| 1436 | # @param $(type) Source type. {C,CXX,AS}
|
---|
[221] | 1437 | # @param bld_type Build type.
|
---|
| 1438 | # @param bld_trg Build target.
|
---|
| 1439 | # @param bld_trg_arch Build target arch.
|
---|
| 1440 | # @param bld_trg_cpu Build target cpu.
|
---|
[729] | 1441 | def_target_source_c_cpp_asm_rc_new = $(kb-src-one )
|
---|
[741] | 1442 | ifdef KMK_VERSION
|
---|
[723] | 1443 | def_target_source_c_cpp_asm_rc_var = def_target_source_c_cpp_asm_rc_new
|
---|
[530] | 1444 | else
|
---|
[723] | 1445 | def_target_source_c_cpp_asm_rc_var = def_target_source_c_cpp_asm_rc_old
|
---|
[530] | 1446 | endif
|
---|
| 1447 |
|
---|
[73] | 1448 | ## Generic macro for processing all target sources.
|
---|
[74] | 1449 | # @param $(target) Normalized target name.
|
---|
[725] | 1450 | # @param $(defpath)
|
---|
| 1451 | # @param much-more...
|
---|
[73] | 1452 | define def_target_sources
|
---|
| 1453 | #$ (warning def_target_sources)
|
---|
| 1454 | # C sources
|
---|
[353] | 1455 | type := C
|
---|
[481] | 1456 | $(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] | 1457 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
[73] | 1458 |
|
---|
| 1459 | # C++ sources
|
---|
[353] | 1460 | type := CXX
|
---|
[481] | 1461 | $(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] | 1462 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
[73] | 1463 |
|
---|
| 1464 | # ASM sources
|
---|
[353] | 1465 | type := AS
|
---|
[481] | 1466 | $(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] | 1467 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
[353] | 1468 |
|
---|
[641] | 1469 | # Resource sources
|
---|
| 1470 | type := RC
|
---|
| 1471 | $(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)))\
|
---|
| 1472 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
| 1473 |
|
---|
[73] | 1474 | endef
|
---|
| 1475 |
|
---|
| 1476 |
|
---|
[219] | 1477 |
|
---|
[353] | 1478 | ## Generic macro for generating the install rule(s) for a target
|
---|
| 1479 | # and update the globals with default out.
|
---|
[219] | 1480 | #
|
---|
[353] | 1481 | # @param $(target) Normalized target name.
|
---|
| 1482 | # @param $(out) The output file.
|
---|
| 1483 | # @param $(definst) The default _INST value.
|
---|
| 1484 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
[729] | 1485 | # @remark Only library uses this now.
|
---|
[353] | 1486 | define def_target_install_pluss
|
---|
| 1487 | ifndef $(target)_NOINST
|
---|
| 1488 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 1489 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
[219] | 1490 |
|
---|
[353] | 1491 | $(eval $(def_link_install_rule))
|
---|
[239] | 1492 |
|
---|
[827] | 1493 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
[272] | 1494 |
|
---|
[353] | 1495 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
[579] | 1496 | $(typevar) += $(INSTARGET_$(target))
|
---|
[219] | 1497 | else
|
---|
[579] | 1498 | $(typevar) += $(out)
|
---|
[219] | 1499 | endif
|
---|
[353] | 1500 | else # _NOINST
|
---|
[579] | 1501 | $(typevar) += $(out)
|
---|
[353] | 1502 | endif
|
---|
| 1503 |
|
---|
[719] | 1504 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
[905] | 1505 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
| 1506 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
[353] | 1507 | _OBJS += $($(target)_OBJS_)
|
---|
| 1508 |
|
---|
[219] | 1509 | endef
|
---|
| 1510 |
|
---|
| 1511 |
|
---|
| 1512 |
|
---|
| 1513 | #
|
---|
[72] | 1514 | # LIBRARIES
|
---|
[73] | 1515 | #
|
---|
[72] | 1516 |
|
---|
| 1517 | ## Library (one).
|
---|
[74] | 1518 | # @param $(target) Normalized library (target) name.
|
---|
[72] | 1519 | define def_lib
|
---|
[145] | 1520 | # library basics
|
---|
[222] | 1521 | ## @todo prefix
|
---|
[353] | 1522 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1523 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 1524 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 1525 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 1526 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
[78] | 1527 | ifeq ($(tool),)
|
---|
[353] | 1528 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
[78] | 1529 | endif
|
---|
[889] | 1530 | name := $(firstword\
|
---|
| 1531 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 1532 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 1533 | $($(target)_NAME.$(bld_trg))\
|
---|
| 1534 | $($(target)_NAME.$(bld_type))\
|
---|
| 1535 | $($(target)_NAME)\
|
---|
| 1536 | $(target))
|
---|
| 1537 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
[743] | 1538 | ifndef PATH_$(target)
|
---|
| 1539 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 1540 | else
|
---|
| 1541 | ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
| 1542 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 1543 | endif
|
---|
| 1544 | endif
|
---|
[353] | 1545 | suff := $(firstword\
|
---|
[481] | 1546 | $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1547 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
[126] | 1548 | $($(target)_LIBSUFF)\
|
---|
[481] | 1549 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1550 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
[126] | 1551 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
[353] | 1552 | $(SUFF_LIB))
|
---|
| 1553 | out := $(outbase)$(suff)
|
---|
| 1554 | TARGET_$(target) := $(out)
|
---|
[719] | 1555 | $(target)_OBJS_ :=
|
---|
[725] | 1556 | defpath := $($(target)_PATH)
|
---|
[145] | 1557 |
|
---|
| 1558 | # source -> object
|
---|
[353] | 1559 | $(eval $(value def_target_sources))
|
---|
[145] | 1560 |
|
---|
| 1561 | # library linking
|
---|
[353] | 1562 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
[889] | 1563 | name := $(firstword\
|
---|
| 1564 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 1565 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 1566 | $($(target)_NAME.$(bld_trg))\
|
---|
| 1567 | $($(target)_NAME.$(bld_type))\
|
---|
| 1568 | $($(target)_NAME)\
|
---|
| 1569 | $(target))
|
---|
| 1570 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
[353] | 1571 | flags :=\
|
---|
[74] | 1572 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
[221] | 1573 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
[74] | 1574 | $(ARFLAGS)\
|
---|
[221] | 1575 | $(ARFLAGS.$(bld_type))\
|
---|
[74] | 1576 | $($(target)_ARFLAGS)\
|
---|
[481] | 1577 | $($(target)_ARFLAGS.$(bld_type)) \
|
---|
| 1578 | $($(target)_ARFLAGS.$(bld_trg)) \
|
---|
| 1579 | $($(target)_ARFLAGS.$(bld_trg_arch)) \
|
---|
| 1580 | $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1581 | $($(target)_ARFLAGS.$(bld_trg_cpu))
|
---|
[353] | 1582 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
| 1583 | $($(target)_SOURCES) \
|
---|
| 1584 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1585 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
[481] | 1586 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
[353] | 1587 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1588 | $($(target)_SOURCES.$(bld_type)))
|
---|
[643] | 1589 | objs = $(filter %.o %.obj, \
|
---|
| 1590 | $($(target)_SOURCES) \
|
---|
| 1591 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1592 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 1593 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1594 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1595 | $($(target)_SOURCES.$(bld_type))) \
|
---|
| 1596 | $($(target)_OBJS_)
|
---|
[353] | 1597 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
| 1598 | deps := $($(target)_DEPS)
|
---|
[827] | 1599 | orderdeps := $($(target)_ORDERDEPS)
|
---|
[72] | 1600 |
|
---|
[725] | 1601 | # Adjust paths if we got a default path.
|
---|
| 1602 | ifneq ($(defpath),)
|
---|
[979] | 1603 | objs := $(abspathex $(objs),$(defpath))
|
---|
| 1604 | deps := $(abspathex $(deps),$(defpath))
|
---|
| 1605 | orderdeps := $(abspathex $(orderdeps),$(defpath))
|
---|
| 1606 | othersrc := $(abspathex $(othersrc),$(defpath))
|
---|
[725] | 1607 | endif
|
---|
| 1608 |
|
---|
[859] | 1609 |
|
---|
| 1610 | # Custom pre-link actions.
|
---|
| 1611 | ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
| 1612 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
| 1613 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
| 1614 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
| 1615 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
| 1616 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
| 1617 | else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
|
---|
| 1618 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
|
---|
| 1619 | else ifdef $(target)_PRE_CMDS.$(bld_trg)
|
---|
| 1620 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
|
---|
| 1621 | else ifdef $(target)_PRE_CMDS.$(bld_type)
|
---|
| 1622 | pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
|
---|
| 1623 | else ifdef $(target)_PRE_CMDS
|
---|
| 1624 | pre_cmds := $($(target)_PRE_CMDS)
|
---|
| 1625 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
| 1626 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
| 1627 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
| 1628 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
| 1629 | else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
| 1630 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
| 1631 | else ifdef PRE_CMDS.$(bld_trg_arch)
|
---|
| 1632 | pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
|
---|
| 1633 | else ifdef PRE_CMDS.$(bld_trg)
|
---|
| 1634 | pre_cmds := $(PRE_CMDS.$(bld_trg))
|
---|
| 1635 | else ifdef PRE_CMDS.$(bld_type)
|
---|
| 1636 | pre_cmds := $(PRE_CMDS.$(bld_type))
|
---|
| 1637 | else
|
---|
| 1638 | pre_cmds := $(PRE_CMDS)
|
---|
| 1639 | endif
|
---|
| 1640 |
|
---|
| 1641 | # Custom post-link actions.
|
---|
| 1642 | ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
| 1643 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
| 1644 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
| 1645 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
| 1646 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
|
---|
| 1647 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
|
---|
| 1648 | else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
|
---|
| 1649 | post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
|
---|
| 1650 | else ifdef $(target)_POST_CMDS.$(bld_trg)
|
---|
| 1651 | post_cmds := $($(target)_POST_CMDS.$(bld_trg))
|
---|
| 1652 | else ifdef $(target)_POST_CMDS.$(bld_type)
|
---|
| 1653 | post_cmds := $($(target)_POST_CMDS.$(bld_type))
|
---|
| 1654 | else ifdef $(target)_POST_CMDS
|
---|
| 1655 | post_cmds := $($(target)_POST_CMDS)
|
---|
| 1656 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
| 1657 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
| 1658 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
| 1659 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
| 1660 | else ifdef POST_CMDS.$(bld_trg).$(bld_type)
|
---|
| 1661 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
|
---|
| 1662 | else ifdef POST_CMDS.$(bld_trg_arch)
|
---|
| 1663 | post_cmds := $(POST_CMDS.$(bld_trg_arch))
|
---|
| 1664 | else ifdef POST_CMDS.$(bld_trg)
|
---|
| 1665 | post_cmds := $(POST_CMDS.$(bld_trg))
|
---|
| 1666 | else ifdef POST_CMDS.$(bld_type)
|
---|
| 1667 | post_cmds := $(POST_CMDS.$(bld_type))
|
---|
| 1668 | else
|
---|
| 1669 | post_cmds := $(POST_CMDS)
|
---|
| 1670 | endif
|
---|
| 1671 |
|
---|
[380] | 1672 | # dependency file
|
---|
| 1673 | dep := $(out)$(SUFF_DEP)
|
---|
[524] | 1674 | ifndef NO_LINK_CMDS_DEPS
|
---|
[893] | 1675 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 1676 | $(eval includedep $(dep))
|
---|
[380] | 1677 | endif
|
---|
[72] | 1678 |
|
---|
[380] | 1679 | # check that the tool is defined.
|
---|
| 1680 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
| 1681 | $(warning kBuild: tools: \
|
---|
[481] | 1682 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1683 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 1684 | 3 $($(target)_$(source)TOOL) \
|
---|
| 1685 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1686 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 1687 | 6 $($(target)_TOOL) \
|
---|
| 1688 | 7 $($(source)TOOL) \
|
---|
| 1689 | 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1690 | 9 $($(source)TOOL.$(bld_trg)) \
|
---|
| 1691 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1692 | 11 $(TOOL.$(bld_trg)) \
|
---|
| 1693 | 12 $(TOOL) )
|
---|
[380] | 1694 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
| 1695 | endif
|
---|
| 1696 |
|
---|
| 1697 | # call the tool
|
---|
| 1698 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
[859] | 1699 | ifneq ($(pre_cmds),)
|
---|
| 1700 | $(target)_CMDS_ := $(TAB)$(pre_cmds)$(NL)$(TAB)$($(target)_CMDS_)
|
---|
| 1701 | endif
|
---|
| 1702 | ifneq ($(post_cmds),)
|
---|
| 1703 | $(target)_CMDS_ := $($(target)_CMDS_)$(NL)$(TAB)$(post_cmds)
|
---|
| 1704 | endif
|
---|
[380] | 1705 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
| 1706 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $(objs)
|
---|
[827] | 1707 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
|
---|
[380] | 1708 |
|
---|
[412] | 1709 | # generate the link rule.
|
---|
[380] | 1710 | $(eval $(def_link_rule))
|
---|
| 1711 |
|
---|
[353] | 1712 | # installing and globals
|
---|
| 1713 | $(eval $(value def_target_install_pluss))
|
---|
[72] | 1714 | endef
|
---|
| 1715 |
|
---|
| 1716 | # Process libraries
|
---|
[859] | 1717 | definst := $(PATH_LIB)
|
---|
| 1718 | typevar := _LIBS
|
---|
[776] | 1719 | tool_do := LINK_LIBRARY
|
---|
[380] | 1720 | mode := 0644
|
---|
[481] | 1721 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
---|
[72] | 1722 |
|
---|
[988] | 1723 | ifdef KBUILD_PROFILE_SELF
|
---|
| 1724 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 1725 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done library targets)
|
---|
| 1726 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 1727 | endif
|
---|
[72] | 1728 |
|
---|
[988] | 1729 |
|
---|
[72] | 1730 | #
|
---|
[353] | 1731 | # Link operations.
|
---|
[72] | 1732 | #
|
---|
| 1733 |
|
---|
[353] | 1734 | ##
|
---|
| 1735 | # Link prolog
|
---|
| 1736 | #
|
---|
| 1737 | # @param $(target) Normalized target name.
|
---|
| 1738 | # @param $(EXT) EXE,DLL,SYS.
|
---|
| 1739 | # @param $(definst) The default _INST value.
|
---|
| 1740 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
[380] | 1741 | define def_link_common
|
---|
[353] | 1742 | # basics
|
---|
| 1743 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 1744 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
| 1745 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
| 1746 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
[145] | 1747 |
|
---|
[353] | 1748 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
[889] | 1749 | name := $(firstword\
|
---|
| 1750 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 1751 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 1752 | $($(target)_NAME.$(bld_trg))\
|
---|
| 1753 | $($(target)_NAME.$(bld_type))\
|
---|
| 1754 | $($(target)_NAME)\
|
---|
| 1755 | $(target))
|
---|
| 1756 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
[743] | 1757 | ifndef PATH_$(target)
|
---|
| 1758 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
| 1759 | else
|
---|
| 1760 | ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
| 1761 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
| 1762 | endif
|
---|
| 1763 | endif
|
---|
[353] | 1764 | suff := $(firstword \
|
---|
| 1765 | $($(target)_$(EXT)SUFF) \
|
---|
| 1766 | $($(target)_$(EXT)SUFF) \
|
---|
| 1767 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
| 1768 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
| 1769 | out := $(outbase)$(suff)
|
---|
| 1770 | TARGET_$(target) := $(out)
|
---|
[719] | 1771 | $(target)_OBJS_ :=
|
---|
[725] | 1772 | defpath := $($(target)_PATH)
|
---|
[353] | 1773 |
|
---|
[145] | 1774 | # source -> object
|
---|
[353] | 1775 | $(eval $(value def_target_sources))
|
---|
[145] | 1776 |
|
---|
[744] | 1777 | # more link stuff.
|
---|
[353] | 1778 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
[889] | 1779 | name := $(firstword\
|
---|
| 1780 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
| 1781 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
| 1782 | $($(target)_NAME.$(bld_trg))\
|
---|
| 1783 | $($(target)_NAME.$(bld_type))\
|
---|
| 1784 | $($(target)_NAME)\
|
---|
| 1785 | $(target))
|
---|
| 1786 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
[353] | 1787 | flags :=\
|
---|
[74] | 1788 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
[221] | 1789 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
| 1790 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
| 1791 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 1792 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1793 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
[74] | 1794 | $(LDFLAGS)\
|
---|
[221] | 1795 | $(LDFLAGS.$(bld_type))\
|
---|
| 1796 | $(LDFLAGS.$(bld_trg))\
|
---|
| 1797 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 1798 | $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1799 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
[74] | 1800 | $($(target)_LDFLAGS)\
|
---|
[221] | 1801 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
| 1802 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
| 1803 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
[481] | 1804 | $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1805 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
| 1806 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
| 1807 | $($(target)_SOURCES)\
|
---|
| 1808 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1809 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
[481] | 1810 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
[353] | 1811 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1812 | $($(target)_SOURCES.$(bld_type)))
|
---|
[643] | 1813 | objs = $(filter %.o %.obj, \
|
---|
| 1814 | $($(target)_SOURCES) \
|
---|
| 1815 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
| 1816 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
| 1817 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1818 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
| 1819 | $($(target)_SOURCES.$(bld_type))) \
|
---|
| 1820 | $($(target)_OBJS_)
|
---|
[353] | 1821 | libs :=\
|
---|
[221] | 1822 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1823 | $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1824 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
| 1825 | $($(target)_LIBS.$(bld_trg))\
|
---|
| 1826 | $($(target)_LIBS.$(bld_type))\
|
---|
[74] | 1827 | $($(target)_LIBS)\
|
---|
[592] | 1828 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1829 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 1830 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1831 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 1832 | $($(target)_SDKS),\
|
---|
[353] | 1833 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1834 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1835 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 1836 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 1837 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 1838 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 1839 | $(LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1840 | $(LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1841 | $(LIBS.$(bld_trg_arch))\
|
---|
| 1842 | $(LIBS.$(bld_trg))\
|
---|
| 1843 | $(LIBS.$(bld_type))\
|
---|
[74] | 1844 | $(LIBS)\
|
---|
[592] | 1845 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1846 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 1847 | $(SDKS.$(bld_trg)) \
|
---|
| 1848 | $(SDKS.$(bld_type)) \
|
---|
| 1849 | $(SDKS),\
|
---|
[353] | 1850 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1851 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1852 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
| 1853 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
| 1854 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
| 1855 | $(SDK_$(sdk)_LIBS))\
|
---|
[221] | 1856 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
[481] | 1857 | $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1858 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
| 1859 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
| 1860 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
[353] | 1861 | $(TOOL_$(tool)_LIBS)
|
---|
| 1862 | libpath :=\
|
---|
[221] | 1863 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1864 | $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1865 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1866 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
| 1867 | $($(target)_LIBPATH.$(bld_type))\
|
---|
[74] | 1868 | $($(target)_LIBPATH)\
|
---|
[592] | 1869 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1870 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
| 1871 | $($(target)_SDKS.$(bld_trg)) \
|
---|
| 1872 | $($(target)_SDKS.$(bld_type)) \
|
---|
| 1873 | $($(target)_SDKS),\
|
---|
[353] | 1874 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1875 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1876 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1877 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 1878 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 1879 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 1880 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1881 | $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1882 | $(LIBPATH.$(bld_trg_arch))\
|
---|
| 1883 | $(LIBPATH.$(bld_trg))\
|
---|
| 1884 | $(LIBPATH.$(bld_type))\
|
---|
[74] | 1885 | $(LIBPATH)\
|
---|
[592] | 1886 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 1887 | $(SDKS.$(bld_trg_arch)) \
|
---|
| 1888 | $(SDKS.$(bld_trg)) \
|
---|
| 1889 | $(SDKS.$(bld_type)) \
|
---|
| 1890 | $(SDKS),\
|
---|
[353] | 1891 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1892 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[353] | 1893 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1894 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
| 1895 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
| 1896 | $(SDK_$(sdk)_LIBPATH))\
|
---|
[221] | 1897 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
[481] | 1898 | $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
[221] | 1899 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
| 1900 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
| 1901 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
[353] | 1902 | $(TOOL_$(tool)_LIBPATH)
|
---|
| 1903 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
| 1904 | deps := $($(target)_DEPS)
|
---|
[827] | 1905 | orderdeps := $($(target)_ORDERDEPS)
|
---|
[353] | 1906 |
|
---|
[725] | 1907 | # Adjust paths if we got a default path.
|
---|
| 1908 | ifneq ($(defpath),)
|
---|
[979] | 1909 | libpath := $(abspathex $(libpath),$(defpath))
|
---|
| 1910 | objs := $(abspathex $(objs),$(defpath))
|
---|
| 1911 | deps := $(abspathex $(deps),$(defpath))
|
---|
| 1912 | orderdeps := $(abspathex $(orderdeps),$(defpath))
|
---|
| 1913 | othersrc := $(abspathex $(othersrc),$(defpath))
|
---|
[725] | 1914 | # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_PATH)/lib if relative to current dir!
|
---|
| 1915 | endif
|
---|
| 1916 |
|
---|
[859] | 1917 | # Custom pre-link actions.
|
---|
| 1918 | ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
| 1919 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
| 1920 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
| 1921 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
| 1922 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
| 1923 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
| 1924 | else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
|
---|
| 1925 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
|
---|
| 1926 | else ifdef $(target)_PRE_CMDS.$(bld_trg)
|
---|
| 1927 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
|
---|
| 1928 | else ifdef $(target)_PRE_CMDS.$(bld_type)
|
---|
| 1929 | pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
|
---|
| 1930 | else ifdef $(target)_PRE_CMDS
|
---|
| 1931 | pre_cmds := $($(target)_PRE_CMDS)
|
---|
| 1932 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
| 1933 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
| 1934 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
| 1935 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
| 1936 | else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
| 1937 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
| 1938 | else ifdef PRE_CMDS.$(bld_trg_arch)
|
---|
| 1939 | pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
|
---|
| 1940 | else ifdef PRE_CMDS.$(bld_trg)
|
---|
| 1941 | pre_cmds := $(PRE_CMDS.$(bld_trg))
|
---|
| 1942 | else ifdef PRE_CMDS.$(bld_type)
|
---|
| 1943 | pre_cmds := $(PRE_CMDS.$(bld_type))
|
---|
| 1944 | else
|
---|
| 1945 | pre_cmds := $(PRE_CMDS)
|
---|
| 1946 | endif
|
---|
[72] | 1947 |
|
---|
[859] | 1948 | # Custom post-link actions.
|
---|
| 1949 | ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
| 1950 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
| 1951 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
| 1952 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
| 1953 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
|
---|
| 1954 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
|
---|
| 1955 | else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
|
---|
| 1956 | post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
|
---|
| 1957 | else ifdef $(target)_POST_CMDS.$(bld_trg)
|
---|
| 1958 | post_cmds := $($(target)_POST_CMDS.$(bld_trg))
|
---|
| 1959 | else ifdef $(target)_POST_CMDS.$(bld_type)
|
---|
| 1960 | post_cmds := $($(target)_POST_CMDS.$(bld_type))
|
---|
| 1961 | else ifdef $(target)_POST_CMDS
|
---|
| 1962 | post_cmds := $($(target)_POST_CMDS)
|
---|
| 1963 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
| 1964 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
| 1965 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
| 1966 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
| 1967 | else ifdef POST_CMDS.$(bld_trg).$(bld_type)
|
---|
| 1968 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
|
---|
| 1969 | else ifdef POST_CMDS.$(bld_trg_arch)
|
---|
| 1970 | post_cmds := $(POST_CMDS.$(bld_trg_arch))
|
---|
| 1971 | else ifdef POST_CMDS.$(bld_trg)
|
---|
| 1972 | post_cmds := $(POST_CMDS.$(bld_trg))
|
---|
| 1973 | else ifdef POST_CMDS.$(bld_type)
|
---|
| 1974 | post_cmds := $(POST_CMDS.$(bld_type))
|
---|
| 1975 | else
|
---|
| 1976 | post_cmds := $(POST_CMDS)
|
---|
| 1977 | endif
|
---|
| 1978 |
|
---|
[353] | 1979 | # installation targets
|
---|
| 1980 | ifndef $(target)_NOINST
|
---|
| 1981 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
| 1982 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
| 1983 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
| 1984 | $(typevar) += $(INSTARGET_$(target))
|
---|
| 1985 | else
|
---|
| 1986 | $(typevar) += $(out)
|
---|
| 1987 | endif
|
---|
| 1988 | # generate the install rule
|
---|
| 1989 | $(eval $(def_link_install_rule))
|
---|
| 1990 |
|
---|
| 1991 | else # NOINST
|
---|
| 1992 | INSTARGET_$(target) :=
|
---|
| 1993 | $(typevar) += $(out)
|
---|
| 1994 | endif # NOINST
|
---|
| 1995 |
|
---|
[380] | 1996 | # dependency file
|
---|
| 1997 | dep := $(outbase)$(SUFF_DEP)
|
---|
[524] | 1998 | ifndef NO_LINK_CMDS_DEPS
|
---|
[893] | 1999 | _DEPFILES_INCLUDED += $(dep)
|
---|
| 2000 | $(eval includedep $(dep))
|
---|
[380] | 2001 | endif
|
---|
[353] | 2002 |
|
---|
[380] | 2003 | # check that the tool is defined.
|
---|
| 2004 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
| 2005 | $(warning kBuild: tools: \
|
---|
[481] | 2006 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2007 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
| 2008 | 3 $($(target)_$(source)TOOL) \
|
---|
| 2009 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2010 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
| 2011 | 6 $($(target)_TOOL) \
|
---|
| 2012 | 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2013 | 8 $($(source)TOOL.$(bld_trg)) \
|
---|
| 2014 | 9 $($(source)TOOL) \
|
---|
| 2015 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2016 | 11 $(TOOL.$(bld_trg)) \
|
---|
| 2017 | 12 $(TOOL) )
|
---|
[380] | 2018 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
| 2019 | endif
|
---|
[353] | 2020 |
|
---|
[380] | 2021 | # call the tool
|
---|
| 2022 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
[859] | 2023 | ifneq ($(pre_cmds),)
|
---|
| 2024 | $(target)_CMDS_ := $(TAB)$(pre_cmds)$(NL)$(TAB)$($(target)_CMDS_)
|
---|
| 2025 | endif
|
---|
| 2026 | ifneq ($(post_cmds),)
|
---|
| 2027 | $(target)_CMDS_ := $($(target)_CMDS_)$(NL)$(TAB)$(post_cmds)
|
---|
| 2028 | endif
|
---|
[380] | 2029 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
| 2030 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $(objs)
|
---|
[827] | 2031 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
|
---|
[353] | 2032 |
|
---|
[412] | 2033 | # generate the link rule.
|
---|
[380] | 2034 | $(eval $(def_link_rule))
|
---|
| 2035 |
|
---|
[412] | 2036 |
|
---|
[380] | 2037 | # Update globals.
|
---|
[579] | 2038 | _OBJS += $($(target)_OBJS_)
|
---|
| 2039 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
[905] | 2040 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
| 2041 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
[827] | 2042 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
[353] | 2043 |
|
---|
| 2044 | endef
|
---|
| 2045 |
|
---|
| 2046 |
|
---|
| 2047 | #
|
---|
| 2048 | # BLDPROGS
|
---|
| 2049 | #
|
---|
| 2050 |
|
---|
| 2051 | ## Build program (one).
|
---|
| 2052 | # @param $(target) Normalized target (program) name.
|
---|
| 2053 | define def_bldprog
|
---|
| 2054 |
|
---|
| 2055 | # set NOINST if not forced installation.
|
---|
| 2056 | ifndef $(target)_INST
|
---|
| 2057 | $(target)_NOINST := 1
|
---|
| 2058 | endif
|
---|
| 2059 |
|
---|
[380] | 2060 | # do the usual stuff.
|
---|
| 2061 | $(eval $(value def_link_common))
|
---|
[353] | 2062 |
|
---|
| 2063 | endef
|
---|
| 2064 |
|
---|
| 2065 | # Process build programs.
|
---|
| 2066 | EXT := EXE
|
---|
| 2067 | EXTPRE := HOST
|
---|
[380] | 2068 | tool_do := LINK_PROGRAM
|
---|
[353] | 2069 | definst := $(PATH_BIN)
|
---|
| 2070 | typevar := _BLDPROGS
|
---|
[380] | 2071 | mode := 0755
|
---|
[353] | 2072 | bld_trg_base_var := PLATFORM
|
---|
[481] | 2073 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), $(eval $(value def_bldprog)))
|
---|
[353] | 2074 |
|
---|
[988] | 2075 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2076 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2077 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done build program targets)
|
---|
| 2078 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2079 | endif
|
---|
[353] | 2080 |
|
---|
| 2081 |
|
---|
| 2082 | #
|
---|
| 2083 | # DLLS
|
---|
| 2084 | #
|
---|
| 2085 |
|
---|
[189] | 2086 | # Process dlls
|
---|
[353] | 2087 | EXT := DLL
|
---|
| 2088 | EXTPRE :=
|
---|
[380] | 2089 | tool_do := LINK_DLL
|
---|
[353] | 2090 | definst := $(PATH_DLL)
|
---|
| 2091 | typevar := _DLLS
|
---|
[830] | 2092 | mode := 0644
|
---|
[353] | 2093 | bld_trg_base_var := TARGET
|
---|
[481] | 2094 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
[74] | 2095 |
|
---|
[988] | 2096 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2097 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2098 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done dll targets)
|
---|
| 2099 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2100 | endif
|
---|
[74] | 2101 |
|
---|
[988] | 2102 |
|
---|
[72] | 2103 | #
|
---|
[830] | 2104 | # IMPORT LIBRARIES
|
---|
[72] | 2105 | #
|
---|
[219] | 2106 | # - On OS/2 and windows these are libraries.
|
---|
[189] | 2107 | # - On other platforms they are fake DLLs.
|
---|
[830] | 2108 | #
|
---|
| 2109 | EXTPRE :=
|
---|
| 2110 | typevar := _IMPORT_LIBS
|
---|
| 2111 | mode := 0644
|
---|
| 2112 | bld_trg_base_var := TARGET
|
---|
[481] | 2113 | ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
|
---|
[830] | 2114 | EXT := LIB
|
---|
| 2115 | tool_do := LINK_LIBRARY
|
---|
| 2116 | definst := $(PATH_LIB)
|
---|
| 2117 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
---|
[189] | 2118 | else
|
---|
[830] | 2119 | EXT := DLL
|
---|
| 2120 | tool_do := LINK_DLL
|
---|
| 2121 | definst := $(PATH_DLL)
|
---|
| 2122 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
[189] | 2123 | endif
|
---|
[72] | 2124 |
|
---|
[988] | 2125 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2126 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2127 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done import library targets)
|
---|
| 2128 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2129 | endif
|
---|
[189] | 2130 |
|
---|
[988] | 2131 |
|
---|
[189] | 2132 | #
|
---|
| 2133 | # PROGRAMS
|
---|
| 2134 | #
|
---|
| 2135 |
|
---|
[353] | 2136 | # Process programs
|
---|
| 2137 | EXT := EXE
|
---|
| 2138 | EXTPRE :=
|
---|
[380] | 2139 | tool_do := LINK_PROGRAM
|
---|
[353] | 2140 | definst := $(PATH_BIN)
|
---|
| 2141 | typevar := _PROGRAMS
|
---|
[380] | 2142 | mode := 0755
|
---|
[353] | 2143 | bld_trg_base_var := TARGET
|
---|
[481] | 2144 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
[130] | 2145 |
|
---|
[988] | 2146 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2147 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2148 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done program targets)
|
---|
| 2149 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2150 | endif
|
---|
[130] | 2151 |
|
---|
[189] | 2152 |
|
---|
[72] | 2153 | #
|
---|
[83] | 2154 | # SYSMODS
|
---|
[72] | 2155 | #
|
---|
| 2156 |
|
---|
[130] | 2157 | # Process sysmods
|
---|
[353] | 2158 | EXT := SYS
|
---|
| 2159 | EXTPRE :=
|
---|
[380] | 2160 | tool_do := LINK_SYSMOD
|
---|
[353] | 2161 | definst := $(PATH_SYS)
|
---|
| 2162 | typevar := _SYSMODS
|
---|
[380] | 2163 | mode := 0644
|
---|
[353] | 2164 | bld_trg_base_var := TARGET
|
---|
[481] | 2165 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
[83] | 2166 |
|
---|
[988] | 2167 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2168 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2169 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done sysmod targets)
|
---|
| 2170 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2171 | endif
|
---|
[83] | 2172 |
|
---|
[988] | 2173 |
|
---|
[72] | 2174 | #
|
---|
| 2175 | # OTHERS
|
---|
| 2176 | #
|
---|
[481] | 2177 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
[72] | 2178 |
|
---|
| 2179 |
|
---|
[353] | 2180 | #
|
---|
| 2181 | # INSTALLS
|
---|
| 2182 | #
|
---|
[72] | 2183 |
|
---|
[353] | 2184 | ## generate the install rule
|
---|
| 2185 | define def_install_src_rule
|
---|
| 2186 | # the install rule
|
---|
| 2187 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
[776] | 2188 | $$(call MSG_INST_FILE,$(srcsrc),$(insdst))
|
---|
[696] | 2189 | $$(QUIET)$$(if $$(filter $(INSTALL),$(inscmd)),,$$(RM) -f $$@)
|
---|
| 2190 | $$(QUIET)$(inscmd)
|
---|
[353] | 2191 | endef
|
---|
| 2192 |
|
---|
| 2193 | ## install one file
|
---|
| 2194 | define def_install_src
|
---|
| 2195 |
|
---|
| 2196 | # deal with '=>' in the source file name.
|
---|
| 2197 | srcdst := $(subst =>, ,$(src))
|
---|
| 2198 | srcsrc := $(firstword $(srcdst))
|
---|
[424] | 2199 | srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
[353] | 2200 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
| 2201 |
|
---|
| 2202 | # _INSTFUN
|
---|
| 2203 | ifdef $(srcsrc)_INSTFUN
|
---|
[725] | 2204 | instfun := $(srcsrc)_INSTFUN
|
---|
[353] | 2205 | else
|
---|
[725] | 2206 | ifdef $(target)_INSTFUN
|
---|
| 2207 | instfun := $(target)_INSTFUN
|
---|
| 2208 | else
|
---|
| 2209 | instfun := _INSTALL_FILE
|
---|
| 2210 | endif
|
---|
[353] | 2211 | endif
|
---|
| 2212 |
|
---|
| 2213 | # _INST
|
---|
| 2214 | ifdef $(srcsrc)_INST
|
---|
[725] | 2215 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
---|
[353] | 2216 | else
|
---|
[725] | 2217 | ifdef $(target)_INST
|
---|
| 2218 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
---|
| 2219 | else
|
---|
| 2220 | inst := $(dir $(srcdstdir))
|
---|
| 2221 | endif
|
---|
[353] | 2222 | endif
|
---|
| 2223 |
|
---|
| 2224 | # calc target
|
---|
[380] | 2225 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
[424] | 2226 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
---|
[353] | 2227 |
|
---|
[414] | 2228 | # mode, uid and gid
|
---|
| 2229 | mode := $(firstword \
|
---|
[481] | 2230 | $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2231 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 2232 | $($(target)_$(srcsrc)_MODE) \
|
---|
[481] | 2233 | $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2234 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
| 2235 | $($(target)_$(srcdst)_MODE) \
|
---|
[481] | 2236 | $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2237 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
| 2238 | $($(srcsrc)_MODE) \
|
---|
[481] | 2239 | $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2240 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
| 2241 | $($(srcdst)_MODE) \
|
---|
[481] | 2242 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2243 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 2244 | $($(target)_MODE))
|
---|
| 2245 | uid := $(firstword \
|
---|
[481] | 2246 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2247 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
| 2248 | $($(target)_$(srcsrc)_UID) \
|
---|
[481] | 2249 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2250 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
| 2251 | $($(target)_$(srcdst)_UID) \
|
---|
[481] | 2252 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2253 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
| 2254 | $($(srcsrc)_UID) \
|
---|
[481] | 2255 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2256 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
| 2257 | $($(srcdst)_UID) \
|
---|
[481] | 2258 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2259 | $($(target)_UID.$(bld_trg)) \
|
---|
| 2260 | $($(target)_UID))
|
---|
| 2261 | gid := $(firstword \
|
---|
[481] | 2262 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2263 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
| 2264 | $($(target)_$(srcsrc)_GID) \
|
---|
[481] | 2265 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2266 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
| 2267 | $($(target)_$(srcdst)_GID) \
|
---|
[481] | 2268 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2269 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
| 2270 | $($(srcsrc)_GID) \
|
---|
[481] | 2271 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2272 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
| 2273 | $($(srcdst)_GID) \
|
---|
[481] | 2274 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[414] | 2275 | $($(target)_GID.$(bld_trg)) \
|
---|
| 2276 | $($(target)_GID))
|
---|
[830] | 2277 | flags := \
|
---|
| 2278 | $($(target)_IFFLAGS) \
|
---|
| 2279 | $($(target)_IFFLAGS.$(bld_trg)) \
|
---|
| 2280 | $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2281 | $($(srcdst)_IFFLAGS) \
|
---|
| 2282 | $($(srcdst)_IFFLAGS.$(bld_trg)) \
|
---|
| 2283 | $($(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2284 | $($(srcsrc)_IFFLAGS) \
|
---|
| 2285 | $($(srcsrc)_IFFLAGS.$(bld_trg)) \
|
---|
| 2286 | $($(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2287 | $($(target)_$(srcdst)_IFFLAGS) \
|
---|
| 2288 | $($(target)_$(srcdst)_IFFLAGS.$(bld_trg)) \
|
---|
| 2289 | $($(target)_$(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2290 | $($(target)_$(srcsrc)_IFFLAGS) \
|
---|
| 2291 | $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg)) \
|
---|
| 2292 | $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
[414] | 2293 |
|
---|
[725] | 2294 |
|
---|
| 2295 | # Adjust the source if we got a default PATH. (This must be done this late!)
|
---|
| 2296 | ifdef $(target)_PATH
|
---|
[979] | 2297 | srcsrc := $(abspathex $(srcsrc),$($(target)_PATH))
|
---|
[725] | 2298 | endif
|
---|
| 2299 |
|
---|
[353] | 2300 | # create the command
|
---|
| 2301 | ifdef $(srcsrc)_INSTALLER
|
---|
[830] | 2302 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
|
---|
| 2303 | else ifdef $(target)_INSTALLER
|
---|
| 2304 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
|
---|
[353] | 2305 | else
|
---|
[830] | 2306 | inscmd := $$(INSTALL)\
|
---|
[414] | 2307 | $(if $(uid),-o $(uid))\
|
---|
| 2308 | $(if $(gid),-g $(gid))\
|
---|
| 2309 | $(if $(mode),-m $(mode))\
|
---|
[830] | 2310 | $(flags)\
|
---|
[414] | 2311 | $(srcsrc) $(insdst)
|
---|
[353] | 2312 | endif
|
---|
| 2313 |
|
---|
| 2314 | # generate the rule (need double evaluation here)
|
---|
| 2315 | $(eval $(def_install_src_rule))
|
---|
| 2316 |
|
---|
| 2317 | INSTARGET_$(target) += $(insdst)
|
---|
| 2318 | endef
|
---|
| 2319 |
|
---|
| 2320 |
|
---|
| 2321 | ## generate the symlink rule
|
---|
| 2322 | define def_install_symlink_rule
|
---|
| 2323 | # the install rule
|
---|
| 2324 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
[776] | 2325 | $$(call MSG_INST_SYM,$(insdst),$(symdst))
|
---|
[696] | 2326 | $$(QUIET)$$(RM) -f $$@
|
---|
| 2327 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
[353] | 2328 | endef
|
---|
| 2329 |
|
---|
| 2330 | ## create one symlink
|
---|
| 2331 | define def_install_symlink
|
---|
| 2332 |
|
---|
| 2333 | # deal with '=>' in the source file name.
|
---|
[380] | 2334 | symdst := $(subst =>, ,$(src))
|
---|
| 2335 | symlnk := $(firstword $(symdst))
|
---|
| 2336 | symdst := $(word $(words $(symdst)),$(symdst))
|
---|
[353] | 2337 |
|
---|
| 2338 | # _INSTFUN
|
---|
[380] | 2339 | ifdef $(symlnk)_INSTFUN
|
---|
[827] | 2340 | instfun := $(symlnk)_INSTFUN
|
---|
| 2341 | else ifdef $(target)_INSTFUN
|
---|
[830] | 2342 | instfun := $(target)_INSTFUN
|
---|
[353] | 2343 | else
|
---|
[827] | 2344 | instfun := _INSTALL_FILE
|
---|
[353] | 2345 | endif
|
---|
| 2346 |
|
---|
| 2347 | # _INST
|
---|
[380] | 2348 | ifdef $(symlnk)_INST
|
---|
[725] | 2349 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
[827] | 2350 | else ifdef $(target)_INST
|
---|
| 2351 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
[353] | 2352 | else
|
---|
[827] | 2353 | inst := $(dir $(symlnk))
|
---|
[353] | 2354 | endif
|
---|
| 2355 |
|
---|
| 2356 | # calc target
|
---|
[380] | 2357 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
| 2358 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
[353] | 2359 |
|
---|
| 2360 | # generate the rule (need double evaluation here)
|
---|
| 2361 | $(eval $(def_install_symlink_rule))
|
---|
| 2362 |
|
---|
| 2363 | INSTARGET_$(target) += $(insdst)
|
---|
| 2364 | endef
|
---|
| 2365 |
|
---|
[412] | 2366 |
|
---|
[380] | 2367 | ## generate the install rule
|
---|
| 2368 | define def_install_directory_rule
|
---|
| 2369 | # the install rule
|
---|
| 2370 | $(insdst):
|
---|
[776] | 2371 | $$(call MSG_INST_DIR,$(insdst))
|
---|
[696] | 2372 | $$(QUIET)$$(INSTALL) -d \
|
---|
[380] | 2373 | $(if $(uid),-o $(uid))\
|
---|
| 2374 | $(if $(gid),-g $(gid))\
|
---|
| 2375 | $(if $(mode),-m $(mode))\
|
---|
[830] | 2376 | $(flags)\
|
---|
[380] | 2377 | $(insdst)
|
---|
[412] | 2378 |
|
---|
| 2379 | .NOTPARALLEL: $(insdst)
|
---|
[380] | 2380 | endef
|
---|
| 2381 |
|
---|
[412] | 2382 |
|
---|
[380] | 2383 | ## create one directory
|
---|
| 2384 | define def_install_directory
|
---|
| 2385 |
|
---|
| 2386 | # _INST
|
---|
| 2387 | ifdef $(directory)_INST
|
---|
[725] | 2388 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
[827] | 2389 | else ifdef $(target)_INST
|
---|
| 2390 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
[380] | 2391 | else
|
---|
[827] | 2392 | inst := $(PATH_INS)
|
---|
[380] | 2393 | endif
|
---|
| 2394 |
|
---|
| 2395 | mode := $(firstword \
|
---|
[481] | 2396 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2397 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
| 2398 | $($(target)_$(directory)_MODE) \
|
---|
[481] | 2399 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2400 | $($(directory)_MODE.$(bld_trg)) \
|
---|
| 2401 | $($(directory)_MODE) \
|
---|
[481] | 2402 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2403 | $($(target)_MODE.$(bld_trg)) \
|
---|
| 2404 | $($(target)_MODE))
|
---|
| 2405 | uid := $(firstword \
|
---|
[481] | 2406 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2407 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
| 2408 | $($(target)_$(directory)_UID) \
|
---|
[481] | 2409 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2410 | $($(directory)_UID.$(bld_trg)) \
|
---|
| 2411 | $($(directory)_UID) \
|
---|
[481] | 2412 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2413 | $($(target)_UID.$(bld_trg)) \
|
---|
| 2414 | $($(target)_UID))
|
---|
| 2415 | gid := $(firstword \
|
---|
[481] | 2416 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2417 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
| 2418 | $($(target)_$(directory)_GID) \
|
---|
[481] | 2419 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2420 | $($(directory)_GID.$(bld_trg)) \
|
---|
| 2421 | $($(directory)_GID) \
|
---|
[481] | 2422 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
[380] | 2423 | $($(target)_GID.$(bld_trg)) \
|
---|
| 2424 | $($(target)_GID))
|
---|
[830] | 2425 | flags := \
|
---|
| 2426 | $($(target)_IDFLAGS)\
|
---|
| 2427 | $($(target)_IDFLAGS.$(bld_trg)) \
|
---|
| 2428 | $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2429 | $($(directory)_IDFLAGS) \
|
---|
| 2430 | $($(directory)_IDFLAGS.$(bld_trg)) \
|
---|
| 2431 | $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
| 2432 | $($(target)_$(directory)_IDFLAGS) \
|
---|
| 2433 | $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
|
---|
| 2434 | $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
[380] | 2435 |
|
---|
| 2436 | insdst := $(inst)/$(directory)/
|
---|
| 2437 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
| 2438 |
|
---|
| 2439 | # generate the rule (need double evaluation here)
|
---|
| 2440 | $(eval $(def_install_directory_rule))
|
---|
| 2441 |
|
---|
| 2442 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
| 2443 | endef
|
---|
| 2444 |
|
---|
| 2445 |
|
---|
[353] | 2446 | ## process one install target.
|
---|
| 2447 | define def_install
|
---|
[744] | 2448 | # the basics.
|
---|
[353] | 2449 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
| 2450 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
| 2451 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
| 2452 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
| 2453 |
|
---|
[827] | 2454 | INSTARGET_$(target) := $($(target)_GOALS)
|
---|
[380] | 2455 | INSTARGET_DIRS_$(target) :=
|
---|
| 2456 |
|
---|
[481] | 2457 | $(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] | 2458 | $(eval $(value def_install_directory)))
|
---|
| 2459 |
|
---|
[481] | 2460 | $(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] | 2461 | $(eval $(value def_install_src)))
|
---|
| 2462 |
|
---|
[481] | 2463 | $(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] | 2464 | $(eval $(value def_install_symlink)))
|
---|
| 2465 |
|
---|
[827] | 2466 | # the collection target
|
---|
| 2467 | TARGET_$(target) := $(PATH_TARGET)/$(target).ins
|
---|
[838] | 2468 | $(TARGET_$(target)): $(INSTARGET_$(target)) | $(INSTARGET_DIRS_$(target)) $(call DIRDEP,$(PATH_TARGET))
|
---|
[827] | 2469 | @$(QUIET2)$(APPEND) $@
|
---|
| 2470 |
|
---|
| 2471 | $(target): $(TARGET_$(target))
|
---|
| 2472 |
|
---|
| 2473 | _INSTALLS += $(TARGET_$(target))
|
---|
| 2474 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
[380] | 2475 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
[905] | 2476 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
| 2477 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
[353] | 2478 | endef
|
---|
| 2479 |
|
---|
| 2480 | ## process all install targets
|
---|
[481] | 2481 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
[353] | 2482 | $(eval $(value def_install)))
|
---|
| 2483 |
|
---|
[988] | 2484 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2485 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2486 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done install targets)
|
---|
| 2487 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2488 | endif
|
---|
[353] | 2489 |
|
---|
[988] | 2490 |
|
---|
[72] | 2491 | #
|
---|
[417] | 2492 | # PACKING
|
---|
| 2493 | #
|
---|
[481] | 2494 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET)) $(PACKING.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
[417] | 2495 |
|
---|
| 2496 |
|
---|
| 2497 | #
|
---|
[72] | 2498 | # DOCS
|
---|
| 2499 | #
|
---|
| 2500 |
|
---|
| 2501 |
|
---|
| 2502 | #
|
---|
[353] | 2503 | # DIRECTORIES
|
---|
| 2504 | #
|
---|
[827] | 2505 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES)))
|
---|
[380] | 2506 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
[353] | 2507 |
|
---|
[380] | 2508 |
|
---|
[353] | 2509 | define def_mkdir_rule
|
---|
| 2510 | $(directory):
|
---|
[776] | 2511 | $$(call MSG_MKDIR,$$@)
|
---|
[696] | 2512 | $$(QUIET)$$(MKDIR) -p $$@
|
---|
[72] | 2513 | endef
|
---|
| 2514 |
|
---|
[353] | 2515 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
[72] | 2516 |
|
---|
[988] | 2517 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2518 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2519 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done directories)
|
---|
| 2520 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2521 | endif
|
---|
[183] | 2522 |
|
---|
[988] | 2523 |
|
---|
[72] | 2524 | #
|
---|
[353] | 2525 | # NOTHING
|
---|
[72] | 2526 | #
|
---|
[353] | 2527 | do-nothing:
|
---|
[988] | 2528 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2529 | @$(ECHO) 'prof: $(int-sub $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(nanots ), $(_KBUILD_TS_PREV)) - executing $@'
|
---|
| 2530 | endif
|
---|
[776] | 2531 | $(call MSG_NOTHING)
|
---|
[72] | 2532 |
|
---|
[183] | 2533 |
|
---|
[75] | 2534 | #
|
---|
[353] | 2535 | # CLEAN UP
|
---|
[75] | 2536 | #
|
---|
[353] | 2537 | do-clean:
|
---|
[776] | 2538 | $(call MSG_CLEAN)
|
---|
[701] | 2539 | $(QUIET)$(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
[966] | 2540 | $(QUIET)$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $(rsort $(dir $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)))
|
---|
[72] | 2541 |
|
---|
[98] | 2542 |
|
---|
[897] | 2543 |
|
---|
[353] | 2544 | #
|
---|
| 2545 | # PASSES (including directory and makefile walking)
|
---|
| 2546 | #
|
---|
[221] | 2547 |
|
---|
[75] | 2548 | ## Subdir
|
---|
| 2549 | # @param $(pass) Lowercase pass name.
|
---|
| 2550 | # @param $(PASS) Uppercase pass name.
|
---|
| 2551 | # @param $(subdir) Subdirectory
|
---|
| 2552 | # @param $(tag) tag to attach to the rule name.
|
---|
| 2553 | define def_pass_subdir
|
---|
[219] | 2554 | pass_$(pass)$(tag):: $(dep)
|
---|
[696] | 2555 | + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
[75] | 2556 | endef
|
---|
[72] | 2557 |
|
---|
[75] | 2558 | ## Submakefile
|
---|
| 2559 | # @param $(pass) Lowercase pass name.
|
---|
| 2560 | # @param $(PASS) Uppercase pass name.
|
---|
| 2561 | # @param $(makefile) Makefile.
|
---|
| 2562 | # @param $(tag) tag to attach to the rule name.
|
---|
| 2563 | define def_pass_makefile
|
---|
[219] | 2564 | pass_$(pass)$(tag):: $(dep)
|
---|
[696] | 2565 | + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
[75] | 2566 | endef
|
---|
[73] | 2567 |
|
---|
[75] | 2568 | ## Execute a pass.
|
---|
| 2569 | # @param $(pass) Lowercase pass name.
|
---|
| 2570 | # @param $(PASS) Uppercase pass name.
|
---|
[353] | 2571 | define def_pass_old
|
---|
[481] | 2572 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2573 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2574 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2575 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
[75] | 2576 |
|
---|
| 2577 | $(eval tag:=_before)
|
---|
[219] | 2578 | $(eval dep:=)
|
---|
[481] | 2579 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 2580 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
[75] | 2581 |
|
---|
| 2582 | $(eval tag:=_after)
|
---|
[219] | 2583 | $(eval dep:=pass_$(pass)_doit)
|
---|
[481] | 2584 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 2585 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 2586 |
|
---|
| 2587 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
| 2588 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
[353] | 2589 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
[272] | 2590 | pass_$(pass)_this: pass_$(pass)_before
|
---|
[696] | 2591 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
[220] | 2592 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
[219] | 2593 | pass_$(pass): pass_$(pass)_after
|
---|
[75] | 2594 |
|
---|
[183] | 2595 | endef
|
---|
| 2596 |
|
---|
[353] | 2597 | define def_pass
|
---|
[481] | 2598 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET.$(BUILD_TARGET_ARCH))) )
|
---|
| 2599 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2600 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
| 2601 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
[183] | 2602 |
|
---|
[353] | 2603 | $(eval tag:=_before)
|
---|
| 2604 | $(eval dep:=)
|
---|
[481] | 2605 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 2606 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
[75] | 2607 |
|
---|
[353] | 2608 | $(eval tag:=_after)
|
---|
| 2609 | $(eval dep:=pass_$(pass)_doit)
|
---|
[481] | 2610 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
| 2611 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
[75] | 2612 |
|
---|
[380] | 2613 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 2614 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
| 2615 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
| 2616 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
| 2617 | pass_$(pass)_this: pass_$(pass)_before
|
---|
[696] | 2618 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
[353] | 2619 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
| 2620 | pass_$(pass): pass_$(pass)_after
|
---|
| 2621 | else
|
---|
[388] | 2622 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
[353] | 2623 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
| 2624 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
| 2625 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
| 2626 | pass_$(pass): \
|
---|
| 2627 | pass_$(pass)_before \
|
---|
| 2628 | pass_$(pass)_doit \
|
---|
[388] | 2629 | pass_$(pass)_after
|
---|
[353] | 2630 | endif
|
---|
[189] | 2631 |
|
---|
[353] | 2632 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
| 2633 | endef
|
---|
[75] | 2634 |
|
---|
[353] | 2635 | # Generate the defined passes.
|
---|
| 2636 | $(foreach PASS, $(PASSES), \
|
---|
| 2637 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 2638 | $(eval $(def_pass)))
|
---|
[75] | 2639 |
|
---|
[219] | 2640 | ## Pass order
|
---|
| 2641 | # @param $(pass) Current pass name.
|
---|
| 2642 | # @param $(prev_pass) The previous pass name.
|
---|
| 2643 | define def_pass_order
|
---|
[380] | 2644 | ifdef KBUILD_SAFE_PARALLEL
|
---|
[353] | 2645 | .NOTPARALLEL: pass_$(pass)_order
|
---|
| 2646 | .PHONY: pass_$(pass)_order
|
---|
[219] | 2647 | pass_$(pass)_order: $(pass_prev)
|
---|
[776] | 2648 | $$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
[696] | 2649 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
[353] | 2650 | else
|
---|
| 2651 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
[388] | 2652 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
[353] | 2653 | pass_$(pass)_banner:
|
---|
[776] | 2654 | $$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
[353] | 2655 | pass_$(pass)_order: \
|
---|
| 2656 | $(pass_prev) \
|
---|
| 2657 | pass_$(pass)_banner \
|
---|
| 2658 | pass_$(pass)
|
---|
| 2659 | endif
|
---|
[219] | 2660 | $(eval pass_prev := pass_$(pass)_order)
|
---|
| 2661 | endef
|
---|
[183] | 2662 |
|
---|
[219] | 2663 | ## PASS: order
|
---|
| 2664 | # Use dependencies to ensure correct pass order.
|
---|
| 2665 | pass_prev :=
|
---|
[353] | 2666 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
| 2667 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
| 2668 | $(eval $(def_pass_order)))
|
---|
[219] | 2669 |
|
---|
[988] | 2670 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2671 | _KBUILD_TS_NOW := $(nanots )
|
---|
| 2672 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done passes)
|
---|
| 2673 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
| 2674 | endif
|
---|
[272] | 2675 |
|
---|
[897] | 2676 |
|
---|
[75] | 2677 | #
|
---|
| 2678 | # THE MAIN RULES
|
---|
| 2679 | #
|
---|
[219] | 2680 | all_recursive: $(pass_prev)
|
---|
[75] | 2681 |
|
---|
[130] | 2682 | rebuild: clean
|
---|
[219] | 2683 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
[78] | 2684 |
|
---|
[412] | 2685 | # @todo make this a non-default pass!
|
---|
[353] | 2686 | uninstall:
|
---|
[827] | 2687 | $(RM) -f $(_INSTALLS_FILES)
|
---|
[412] | 2688 |
|
---|
[380] | 2689 | install: pass_installs
|
---|
[78] | 2690 |
|
---|
[75] | 2691 | # misc shortcuts.
|
---|
[380] | 2692 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
[75] | 2693 | objects: $(_OBJS)
|
---|
[222] | 2694 | bldprogs: $(_BLDPROGS)
|
---|
[189] | 2695 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
[205] | 2696 | dlls: $(_DLLS)
|
---|
[219] | 2697 | programs: $(_PROGRAMS)
|
---|
[205] | 2698 | sysmods: $(_SYSMODS)
|
---|
[353] | 2699 | others: $(_OTHERS)
|
---|
[854] | 2700 | installs: $(_INSTALLS) $(_INSTALLS_DIRS) $(_INSTALLS_FILES)
|
---|
[75] | 2701 |
|
---|
| 2702 |
|
---|
[897] | 2703 |
|
---|
[353] | 2704 | #
|
---|
| 2705 | # kBuild debugging stuff.
|
---|
| 2706 | #
|
---|
| 2707 | show_targets:
|
---|
[984] | 2708 | @$(foreach target, $(_ALL_TARGETS),\
|
---|
[353] | 2709 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
| 2710 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
| 2711 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
| 2712 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
[660] | 2713 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) OBJS_ CLEAN, \
|
---|
[353] | 2714 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 2715 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
| 2716 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
| 2717 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
| 2718 | )\
|
---|
| 2719 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
| 2720 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
| 2721 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
| 2722 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
| 2723 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
| 2724 | ))
|
---|
| 2725 |
|
---|
| 2726 |
|
---|
| 2727 |
|
---|
| 2728 | #
|
---|
| 2729 | # Include dependency files.
|
---|
| 2730 | #
|
---|
[893] | 2731 | ifneq ($(_DEPFILES),)
|
---|
| 2732 | includedep $(_DEPFILES)
|
---|
| 2733 | endif
|
---|
[353] | 2734 |
|
---|
| 2735 |
|
---|
[988] | 2736 | ifdef KBUILD_PROFILE_SELF
|
---|
| 2737 | _KBUILD_TS_FOOTER_END := $(nanots )
|
---|
| 2738 | $(info prof: $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_PREV)) - end of footer.kmk)
|
---|
| 2739 | $(info prof: footer.kmk: $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_FOOTER_START)))
|
---|
| 2740 | _KBUILD_TS_PREV := $(_KBUILD_TS_FOOTER_END)
|
---|
| 2741 | endif
|
---|
| 2742 |
|
---|
[72] | 2743 | # end-of-file-content
|
---|
[106] | 2744 | __footer_kmk__ := target
|
---|
[72] | 2745 | endif # __footer_kmk__
|
---|
[438] | 2746 |
|
---|