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