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