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