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