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