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