| 1 | # $Id: footer.kmk 1441 2008-03-30 05:31:21Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | #
|
|---|
| 4 | # kBuild - File included at top of makefile.
|
|---|
| 5 | #
|
|---|
| 6 | # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
|
|---|
| 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
|
|---|
| 13 | # the Free Software Foundation; either version source of the License, or
|
|---|
| 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
|
|---|
| 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 24 | #
|
|---|
| 25 | #
|
|---|
| 26 |
|
|---|
| 27 | ifndef __footer_kmk__
|
|---|
| 28 | # start-of-file-content
|
|---|
| 29 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 30 | _KBUILD_TS_FOOTER_START := $(nanots )
|
|---|
| 31 | $(info prof: $(int-sub $(_KBUILD_TS_FOOTER_START), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_FOOTER_START), $(_KBUILD_TS_PREV)) - start of footer.kmk)
|
|---|
| 32 | $(info stat: $(make-stats ))
|
|---|
| 33 | _KBUILD_TS_PREV := $(_KBUILD_TS_FOOTER_START)
|
|---|
| 34 | endif
|
|---|
| 35 |
|
|---|
| 36 | #
|
|---|
| 37 | # Variables.
|
|---|
| 38 | # (Some of these need initialization before including definitions using them.)
|
|---|
| 39 | #
|
|---|
| 40 |
|
|---|
| 41 | # All targets of each types.
|
|---|
| 42 | _ALL_BLDPROGS := $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(BUILD_PLATFORM_CPU)) $(BLDPROGS.$(BUILD_TYPE))
|
|---|
| 43 | _ALL_LIBRARIES := $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(LIBRARIES.$(BUILD_TARGET_ARCH)) $(LIBRARIES.$(BUILD_TARGET_CPU)) $(LIBRARIES.$(BUILD_TYPE))
|
|---|
| 44 | _ALL_IMPORT_LIBS := $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(BUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(BUILD_TARGET_CPU)) $(IMPORT_LIBS.$(BUILD_TYPE))
|
|---|
| 45 | _ALL_DLLS := $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(DLLS.$(BUILD_TARGET_ARCH)) $(DLLS.$(BUILD_TARGET_CPU)) $(DLLS.$(BUILD_TYPE))
|
|---|
| 46 | _ALL_PROGRAMS := $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(PROGRAMS.$(BUILD_TARGET_ARCH)) $(PROGRAMS.$(BUILD_TARGET_CPU)) $(PROGRAMS.$(BUILD_TYPE))
|
|---|
| 47 | _ALL_SYSMODS := $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(SYSMODS.$(BUILD_TARGET_ARCH)) $(SYSMODS.$(BUILD_TARGET_CPU)) $(SYSMODS.$(BUILD_TYPE))
|
|---|
| 48 | _ALL_OTHERS := $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(OTHERS.$(BUILD_TARGET_ARCH)) $(OTHERS.$(BUILD_TARGET_CPU)) $(OTHERS.$(BUILD_TYPE))
|
|---|
| 49 | _ALL_INSTALLS := $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(INSTALLS.$(BUILD_TARGET_ARCH)) $(INSTALLS.$(BUILD_TARGET_CPU)) $(INSTALLS.$(BUILD_TYPE))
|
|---|
| 50 | _ALL_FETCHES := $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(FETCHES.$(BUILD_TARGET_ARCH)) $(FETCHES.$(BUILD_TARGET_CPU)) $(FETCHES.$(BUILD_TYPE))
|
|---|
| 51 | _ALL_PATCHES := $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(PATCHES.$(BUILD_TARGET_ARCH)) $(PATCHES.$(BUILD_TARGET_CPU)) $(PATCHES.$(BUILD_TYPE))
|
|---|
| 52 |
|
|---|
| 53 | # all targets.
|
|---|
| 54 | _ALL_TARGETS = \
|
|---|
| 55 | $(_ALL_FETCHES) \
|
|---|
| 56 | $(_ALL_PATCHES) \
|
|---|
| 57 | $(_ALL_BLDPROGS) \
|
|---|
| 58 | $(_ALL_LIBRARIES) \
|
|---|
| 59 | $(_ALL_IMPORT_LIBS) \
|
|---|
| 60 | $(_ALL_DLLS) \
|
|---|
| 61 | $(_ALL_PROGRAMS) \
|
|---|
| 62 | $(_ALL_SYSMODS) \
|
|---|
| 63 | $(_ALL_INSTALLS) \
|
|---|
| 64 | $(_ALL_OTHERS)
|
|---|
| 65 |
|
|---|
| 66 | # all $(BUILD_TARGET) targets.
|
|---|
| 67 | _ALL_BUILD_TARGET_TARGETS = \
|
|---|
| 68 | $(_ALL_FETCHES) \
|
|---|
| 69 | $(_ALL_PATCHES) \
|
|---|
| 70 | $(_ALL_LIBRARIES) \
|
|---|
| 71 | $(_ALL_IMPORT_LIBS) \
|
|---|
| 72 | $(_ALL_DLLS) \
|
|---|
| 73 | $(_ALL_PROGRAMS) \
|
|---|
| 74 | $(_ALL_SYSMODS) \
|
|---|
| 75 | $(_ALL_INSTALLS) \
|
|---|
| 76 | $(_ALL_OTHERS)
|
|---|
| 77 |
|
|---|
| 78 | # all $(BUILD_PLATFORM) targets.
|
|---|
| 79 | _ALL_BUILD_PLATFORM_TARGETS = \
|
|---|
| 80 | $(_ALL_BLDPROGS)
|
|---|
| 81 |
|
|---|
| 82 | # all targets making use of srcname.
|
|---|
| 83 | _ALL_SRCNAME_TARGETS = \
|
|---|
| 84 | $(_ALL_FETCHES) \
|
|---|
| 85 | $(_ALL_PATCHES)
|
|---|
| 86 |
|
|---|
| 87 | # dependency files.
|
|---|
| 88 | _DEPFILES :=
|
|---|
| 89 |
|
|---|
| 90 | # included dependency files.
|
|---|
| 91 | _DEPFILES_INCLUDED :=
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 | # All kind of output files except for _OBJS and _DEPFILES.
|
|---|
| 95 | # Compiling or linking definition outputting other things that $@ and any
|
|---|
| 96 | # required dependency file must add those output files to this variable.
|
|---|
| 97 | _OUT_FILES :=
|
|---|
| 98 |
|
|---|
| 99 | # Files which only requires cleaning up.
|
|---|
| 100 | _CLEAN_FILES :=
|
|---|
| 101 |
|
|---|
| 102 | # all of a type
|
|---|
| 103 | _OBJS :=
|
|---|
| 104 | _FETCHES :=
|
|---|
| 105 | _DOWNLOADS:=
|
|---|
| 106 | _UNPACKS :=
|
|---|
| 107 | _PATCHES :=
|
|---|
| 108 | _UNFETCHES:=
|
|---|
| 109 | _BLDPROGS :=
|
|---|
| 110 | _LIBS :=
|
|---|
| 111 | _DLLS :=
|
|---|
| 112 | _PROGRAMS :=
|
|---|
| 113 | _SYSMODS :=
|
|---|
| 114 | _INSTALLS :=
|
|---|
| 115 | _INSTALLS_FILES :=
|
|---|
| 116 | _INSTALLS_DIRS :=
|
|---|
| 117 | _OTHERS :=
|
|---|
| 118 | _PACKING :=
|
|---|
| 119 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS)
|
|---|
| 120 | _IMPORT_LIBS :=
|
|---|
| 121 |
|
|---|
| 122 | # misc
|
|---|
| 123 | pass_prev :=
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 | #
|
|---|
| 128 | # Footer macros
|
|---|
| 129 | #
|
|---|
| 130 |
|
|---|
| 131 | ## Figure out the tool for a target.
|
|---|
| 132 | # @param $1 normalized target.
|
|---|
| 133 | # @param $2 tooltype.
|
|---|
| 134 | # @param bld_trg build target.
|
|---|
| 135 | # @param bld_trg_arch build target architecture.
|
|---|
| 136 | _TARGET_TOOL = $(strip $(firstword \
|
|---|
| 137 | $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 138 | $($(1)_$(2)TOOL.$(bld_trg)) \
|
|---|
| 139 | $($(1)_$(2)TOOL) \
|
|---|
| 140 | $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 141 | $($(1)_TOOL.$(bld_trg)) \
|
|---|
| 142 | $($(1)_TOOL) \
|
|---|
| 143 | $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 144 | $($(2)TOOL.$(bld_trg)) \
|
|---|
| 145 | $($(2)TOOL) \
|
|---|
| 146 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 147 | $(TOOL.$(bld_trg)) \
|
|---|
| 148 | $(TOOL) \
|
|---|
| 149 | ))
|
|---|
| 150 |
|
|---|
| 151 | ## Figure out the actual name of an installed file.
|
|---|
| 152 | # @param $1 The file to install.
|
|---|
| 153 | # @param $2 The target name.
|
|---|
| 154 | # @param $3 The _INST value (can be empty).
|
|---|
| 155 | # @param $4 The default directory to use when $3 is empty.
|
|---|
| 156 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | ## Inherit one keyword in a non-accumulative manner.
|
|---|
| 161 | # @param $(trg) Target object.
|
|---|
| 162 | # @param $(prop) The property.
|
|---|
| 163 | # @param $(src_key) Source keyword.
|
|---|
| 164 | # @param $(trg_key) Target keyword.
|
|---|
| 165 | define def_inherit_one_keyword
|
|---|
| 166 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 167 | ifndef $(trg)_$(prop).$(trg_key)
|
|---|
| 168 | $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key))
|
|---|
| 169 | endif
|
|---|
| 170 | endif
|
|---|
| 171 | endef
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 | # EXPAND_BY = overriding
|
|---|
| 175 |
|
|---|
| 176 | ## Inherit one keyword in a non-accumulative manner.
|
|---|
| 177 | # @param $(trg) Target object.
|
|---|
| 178 | # @param $(prop) The property.
|
|---|
| 179 | # @param $(src_key) Source keyword.
|
|---|
| 180 | # @param $(trg_key) Target keyword.
|
|---|
| 181 | define def_inherit_one_keyword_overriding_now_l
|
|---|
| 182 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 183 | ifndef $(trg)_$(prop).$(trg_key)
|
|---|
| 184 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
|---|
| 185 | endif
|
|---|
| 186 | endif
|
|---|
| 187 | endef
|
|---|
| 188 |
|
|---|
| 189 | ## @copydoc def_inherit_one_overriding_now_l
|
|---|
| 190 | define def_inherit_one_keyword_overriding_now_r
|
|---|
| 191 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 192 | ifndef $(trg)_$(prop).$(trg_key)
|
|---|
| 193 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
|---|
| 194 | endif
|
|---|
| 195 | endif
|
|---|
| 196 | endef
|
|---|
| 197 |
|
|---|
| 198 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
|---|
| 199 | # @param $(trg) Target object.
|
|---|
| 200 | # @param $(prop) The property.
|
|---|
| 201 | # @param $(src_key) Source keyword.
|
|---|
| 202 | # @param $(trg_key) Target keyword.
|
|---|
| 203 | # @remark This define relies on double evaluation
|
|---|
| 204 | define def_inherit_one_keyword_overriding_deferred
|
|---|
| 205 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 206 | ifndef $(trg)_$(prop).$(trg_key)
|
|---|
| 207 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
|---|
| 208 | endif
|
|---|
| 209 | endif
|
|---|
| 210 | endef
|
|---|
| 211 |
|
|---|
| 212 | ## @copydoc def_inherit_one_overriding_deferred
|
|---|
| 213 | define def_inherit_one_keyword_overriding_deferred_l
|
|---|
| 214 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 215 | ifndef $(trg)_$(prop).$(trg_key)
|
|---|
| 216 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
|---|
| 217 | endif
|
|---|
| 218 | endif
|
|---|
| 219 | endef
|
|---|
| 220 |
|
|---|
| 221 | ## @copydoc def_inherit_one_overriding_deferred
|
|---|
| 222 | define def_inherit_one_keyword_overriding_deferred_r
|
|---|
| 223 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 224 | ifndef $(trg)_$(prop).$(trg_key)
|
|---|
| 225 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
|---|
| 226 | endif
|
|---|
| 227 | endif
|
|---|
| 228 | endef
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 | # EXPAND_BY = prepending
|
|---|
| 232 |
|
|---|
| 233 | ## Inherit one keyword in a prepending manner.
|
|---|
| 234 | # @param $(trg) Target object.
|
|---|
| 235 | # @param $(prop) The property.
|
|---|
| 236 | # @param $(src_key) Source keyword.
|
|---|
| 237 | # @param $(trg_key) Target keyword.
|
|---|
| 238 | define def_inherit_one_keyword_prepending_now_l
|
|---|
| 239 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 240 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
|---|
| 241 | endif
|
|---|
| 242 | endef
|
|---|
| 243 |
|
|---|
| 244 | ## @copydoc def_inherit_one_prepending_now_l
|
|---|
| 245 | define def_inherit_one_keyword_prepending_now_r
|
|---|
| 246 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 247 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
|---|
| 248 | endif
|
|---|
| 249 | endef
|
|---|
| 250 |
|
|---|
| 251 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
|---|
| 252 | # @param $(trg) Target object.
|
|---|
| 253 | # @param $(prop) The property.
|
|---|
| 254 | # @param $(src_key) Source keyword.
|
|---|
| 255 | # @param $(trg_key) Target keyword.
|
|---|
| 256 | # @remark This define relies on double evaluation
|
|---|
| 257 | define def_inherit_one_keyword_prepending_deferred
|
|---|
| 258 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 259 | ifndef $(trg)_$(prop).$(trg_key)
|
|---|
| 260 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
|---|
| 261 | endif
|
|---|
| 262 | endif
|
|---|
| 263 | endef
|
|---|
| 264 |
|
|---|
| 265 | ## Inherit one keyword in a prepending manner, deferred expansion.
|
|---|
| 266 | # @param $(trg) Target object.
|
|---|
| 267 | # @param $(prop) The property.
|
|---|
| 268 | # @param $(src_key) Source keyword.
|
|---|
| 269 | # @param $(trg_key) Target keyword.
|
|---|
| 270 | define def_inherit_one_keyword_prepending_deferred_l
|
|---|
| 271 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 272 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
|---|
| 273 | endif
|
|---|
| 274 | endef
|
|---|
| 275 |
|
|---|
| 276 | ## @copydoc def_inherit_one_prepending_deferred_l
|
|---|
| 277 | define def_inherit_one_keyword_prepending_deferred_r
|
|---|
| 278 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 279 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
|---|
| 280 | endif
|
|---|
| 281 | endef
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 | # EXPAND_BY = appending
|
|---|
| 285 |
|
|---|
| 286 | ## Inherit one keyword in an appending manner.
|
|---|
| 287 | # @param $(trg) Target object.
|
|---|
| 288 | # @param $(prop) The property.
|
|---|
| 289 | # @param $(src_key) Source keyword.
|
|---|
| 290 | # @param $(trg_key) Target keyword.
|
|---|
| 291 | define def_inherit_one_keyword_appending_now_l
|
|---|
| 292 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 293 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
|---|
| 294 | endif
|
|---|
| 295 | endef
|
|---|
| 296 |
|
|---|
| 297 | ## @copydoc def_inherit_one_appending_now_l
|
|---|
| 298 | define def_inherit_one_keyword_appending_now_r
|
|---|
| 299 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 300 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
|---|
| 301 | endif
|
|---|
| 302 | endef
|
|---|
| 303 |
|
|---|
| 304 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
|---|
| 305 | # @param $(trg) Target object.
|
|---|
| 306 | # @param $(prop) The property.
|
|---|
| 307 | # @param $(src_key) Source keyword.
|
|---|
| 308 | # @param $(trg_key) Target keyword.
|
|---|
| 309 | # @remark This define relies on double evaluation
|
|---|
| 310 | define def_inherit_one_keyword_appending_deferred
|
|---|
| 311 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 312 | ifndef $(trg)_$(prop).$(trg_key)
|
|---|
| 313 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
|---|
| 314 | endif
|
|---|
| 315 | endif
|
|---|
| 316 | endef
|
|---|
| 317 |
|
|---|
| 318 | ## Inherit one keyword in an appending manner, deferred expansion.
|
|---|
| 319 | # @param $(trg) Target object.
|
|---|
| 320 | # @param $(prop) The property.
|
|---|
| 321 | # @param $(src_key) Source keyword.
|
|---|
| 322 | # @param $(trg_key) Target keyword.
|
|---|
| 323 | define def_inherit_one_keyword_appending_deferred_l
|
|---|
| 324 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 325 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
|---|
| 326 | endif
|
|---|
| 327 | endef
|
|---|
| 328 |
|
|---|
| 329 | ## @copydoc def_inherit_one_appending_deferred_l
|
|---|
| 330 | define def_inherit_one_keyword_appending_deferred_r
|
|---|
| 331 | ifdef $(trg)_$(prop).$(src_key)
|
|---|
| 332 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
|---|
| 333 | endif
|
|---|
| 334 | endef
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 | ## Worker fro def_inherit that deals with one keyword that makes
|
|---|
| 338 | # use of inheritance.
|
|---|
| 339 | # @param prefix_keyword key_prefix:keyword. The cool join/split game as usual.
|
|---|
| 340 | # @param trg Object to consider for inheriting.
|
|---|
| 341 | # @param properties List of the properties with straight expansion.
|
|---|
| 342 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
|---|
| 343 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
|---|
| 344 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
|---|
| 345 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
|---|
| 346 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
|---|
| 347 | define def_inherit_keyword
|
|---|
| 348 | prefix := $(word 1,$(subst :, ,$(prefix_keyword)))
|
|---|
| 349 | trg_key := $(word 2,$(subst :, ,$(prefix_keyword)))
|
|---|
| 350 | src_key := $($(prefix)_$(trg_key)_EXTENDS)
|
|---|
| 351 | by := $($(prefix)_$(trg_key)_EXTENDS_BY)
|
|---|
| 352 |
|
|---|
| 353 | # Inherit the properties.
|
|---|
| 354 | $(foreach prop, $(properties), $(eval $(def_inherit_one_keyword)))
|
|---|
| 355 | $(foreach prop, $(properties_now_l), $(eval $(def_inherit_one_keyword_$(by)_now_l)))
|
|---|
| 356 | $(foreach prop, $(properties_now_r), $(eval $(def_inherit_one_keyword_$(by)_now_r)))
|
|---|
| 357 | $(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_keyword_$(by)_deferred)))
|
|---|
| 358 | $(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l)))
|
|---|
| 359 | $(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r)))
|
|---|
| 360 |
|
|---|
| 361 | endef # def_inherit_keyword
|
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 | ## Inherit one template property in a non-accumulative manner.
|
|---|
| 365 | # @param $(prop) Property name
|
|---|
| 366 | # @param $(src) Source (parent) object.
|
|---|
| 367 | # @param $(trg) Target (child) object.
|
|---|
| 368 | define def_inherit_one
|
|---|
| 369 | ifdef $(src)_$(prop)
|
|---|
| 370 | ifndef $(trg)_$(prop)
|
|---|
| 371 | $(trg)_$(prop) = $($(src)_$(prop))
|
|---|
| 372 | endif
|
|---|
| 373 | endif
|
|---|
| 374 | endef
|
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 | # EXPAND_BY = overriding
|
|---|
| 378 |
|
|---|
| 379 | ## Inherit one template property in a non-accumulative manner.
|
|---|
| 380 | # @param $(prop) Property name
|
|---|
| 381 | # @param $(src) Source (parent) object.
|
|---|
| 382 | # @param $(trg) Target (child) object.
|
|---|
| 383 | define def_inherit_one_overriding_now_l
|
|---|
| 384 | ifdef $(src)_$(prop)
|
|---|
| 385 | ifndef $(trg)_$(prop)
|
|---|
| 386 | $(trg)_$(prop) := $($(src)_$(prop))
|
|---|
| 387 | endif
|
|---|
| 388 | endif
|
|---|
| 389 | endef
|
|---|
| 390 |
|
|---|
| 391 | ## @copydoc def_inherit_one_overriding_now_l
|
|---|
| 392 | define def_inherit_one_overriding_now_r
|
|---|
| 393 | ifdef $(src)_$(prop)
|
|---|
| 394 | ifndef $(trg)_$(prop)
|
|---|
| 395 | $(trg)_$(prop) := $($(src)_$(prop))
|
|---|
| 396 | endif
|
|---|
| 397 | endif
|
|---|
| 398 | endef
|
|---|
| 399 |
|
|---|
| 400 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
|---|
| 401 | # @param $(prop) Property name
|
|---|
| 402 | # @param $(src) Source
|
|---|
| 403 | # @param $(trg) Target
|
|---|
| 404 | # @remark This define relies on double evaluation
|
|---|
| 405 | define def_inherit_one_overriding_deferred
|
|---|
| 406 | ifdef $(src)_$(prop)
|
|---|
| 407 | ifndef $(trg)_$(prop)
|
|---|
| 408 | $(trg)_$(prop) = $$($(src)_$(prop))
|
|---|
| 409 | endif
|
|---|
| 410 | endif
|
|---|
| 411 | endef
|
|---|
| 412 |
|
|---|
| 413 | ## @copydoc def_inherit_one_overriding_deferred
|
|---|
| 414 | define def_inherit_one_overriding_deferred_l
|
|---|
| 415 | ifdef $(src)_$(prop)
|
|---|
| 416 | ifndef $(trg)_$(prop)
|
|---|
| 417 | $(trg)_$(prop) = $$($(src)_$(prop))
|
|---|
| 418 | endif
|
|---|
| 419 | endif
|
|---|
| 420 | endef
|
|---|
| 421 |
|
|---|
| 422 | ## @copydoc def_inherit_one_overriding_deferred
|
|---|
| 423 | define def_inherit_one_overriding_deferred_r
|
|---|
| 424 | ifdef $(src)_$(prop)
|
|---|
| 425 | ifndef $(trg)_$(prop)
|
|---|
| 426 | $(trg)_$(prop) = $$($(src)_$(prop))
|
|---|
| 427 | endif
|
|---|
| 428 | endif
|
|---|
| 429 | endef
|
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 | # EXPAND_BY = prepending
|
|---|
| 433 |
|
|---|
| 434 | ## Inherit one template property in a prepending manner.
|
|---|
| 435 | # @param $(prop) Property name
|
|---|
| 436 | # @param $(src) Source (parent) object.
|
|---|
| 437 | # @param $(trg) Target (child) object.
|
|---|
| 438 | define def_inherit_one_prepending_now_l
|
|---|
| 439 | ifdef $(src)_$(prop)
|
|---|
| 440 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
|---|
| 441 | endif
|
|---|
| 442 | endef
|
|---|
| 443 |
|
|---|
| 444 | ## @copydoc def_inherit_one_prepending_now_l
|
|---|
| 445 | define def_inherit_one_prepending_now_r
|
|---|
| 446 | ifdef $(src)_$(prop)
|
|---|
| 447 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
|---|
| 448 | endif
|
|---|
| 449 | endef
|
|---|
| 450 |
|
|---|
| 451 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
|---|
| 452 | # @param $(prop) Property name
|
|---|
| 453 | # @param $(src) Source
|
|---|
| 454 | # @param $(trg) Target
|
|---|
| 455 | # @remark This define relies on double evaluation
|
|---|
| 456 | define def_inherit_one_prepending_deferred
|
|---|
| 457 | ifdef $(src)_$(prop)
|
|---|
| 458 | ifndef $(trg)_$(prop)
|
|---|
| 459 | $(trg)_$(prop) = $$($(src)_$(prop))
|
|---|
| 460 | endif
|
|---|
| 461 | endif
|
|---|
| 462 | endef
|
|---|
| 463 |
|
|---|
| 464 | ## Inherit one template property in a prepending manner, deferred expansion.
|
|---|
| 465 | # @param $(prop) Property name
|
|---|
| 466 | # @param $(src) Source (parent) object.
|
|---|
| 467 | # @param $(trg) Target (child) object.
|
|---|
| 468 | define def_inherit_one_prepending_deferred_l
|
|---|
| 469 | ifdef $(src)_$(prop)
|
|---|
| 470 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
|---|
| 471 | endif
|
|---|
| 472 | endef
|
|---|
| 473 |
|
|---|
| 474 | ## @copydoc def_inherit_one_prepending_deferred_l
|
|---|
| 475 | define def_inherit_one_prepending_deferred_r
|
|---|
| 476 | ifdef $(src)_$(prop)
|
|---|
| 477 | $(trg)_$(prop) += $$($(src)_$(prop))
|
|---|
| 478 | endif
|
|---|
| 479 | endef
|
|---|
| 480 |
|
|---|
| 481 |
|
|---|
| 482 | # EXPAND_BY = appending
|
|---|
| 483 |
|
|---|
| 484 | ## Inherit one template property in an appending manner.
|
|---|
| 485 | # @param $(prop) Property name
|
|---|
| 486 | # @param $(src) Source (parent) object.
|
|---|
| 487 | # @param $(trg) Target (child) object.
|
|---|
| 488 | define def_inherit_one_appending_now_l
|
|---|
| 489 | ifdef $(src)_$(prop)
|
|---|
| 490 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
|---|
| 491 | endif
|
|---|
| 492 | endef
|
|---|
| 493 |
|
|---|
| 494 | ## @copydoc def_inherit_one_appending_now_l
|
|---|
| 495 | define def_inherit_one_appending_now_r
|
|---|
| 496 | ifdef $(src)_$(prop)
|
|---|
| 497 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
|---|
| 498 | endif
|
|---|
| 499 | endef
|
|---|
| 500 |
|
|---|
| 501 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
|---|
| 502 | # @param $(prop) Property name
|
|---|
| 503 | # @param $(src) Source
|
|---|
| 504 | # @param $(trg) Target
|
|---|
| 505 | # @remark This define relies on double evaluation
|
|---|
| 506 | define def_inherit_one_appending_deferred
|
|---|
| 507 | ifdef $(src)_$(prop)
|
|---|
| 508 | ifndef $(trg)_$(prop)
|
|---|
| 509 | $(trg)_$(prop) = $$($(src)_$(prop))
|
|---|
| 510 | endif
|
|---|
| 511 | endif
|
|---|
| 512 | endef
|
|---|
| 513 |
|
|---|
| 514 | ## Inherit one template property in an appending manner, deferred expansion.
|
|---|
| 515 | # @param $(prop) Property name
|
|---|
| 516 | # @param $(src) Source (parent) object.
|
|---|
| 517 | # @param $(trg) Target (child) object.
|
|---|
| 518 | define def_inherit_one_appending_deferred_l
|
|---|
| 519 | ifdef $(src)_$(prop)
|
|---|
| 520 | $(trg)_$(prop) += $$($(src)_$(prop))
|
|---|
| 521 | endif
|
|---|
| 522 | endef
|
|---|
| 523 |
|
|---|
| 524 | ## @copydoc def_inherit_one_appending_deferred_l
|
|---|
| 525 | define def_inherit_one_appending_deferred_r
|
|---|
| 526 | ifdef $(src)_$(prop)
|
|---|
| 527 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
|---|
| 528 | endif
|
|---|
| 529 | endef
|
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 | ## combines the specified properties $(1) with the $(_KEYWORDS) list.
|
|---|
| 533 | _INHERIT_JOIN_KEYWORDS = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
|
|---|
| 534 |
|
|---|
| 535 |
|
|---|
| 536 | ## Generic inheritance for use with targets templates and tools.
|
|---|
| 537 | # @param trg Object to consider for inheriting.
|
|---|
| 538 | # @param src_prefix What to prefix the value found in EXTENDS with to get the object.
|
|---|
| 539 | # @param load_function Load function for stuff that needs
|
|---|
| 540 | # @param properties List of the properties with straight expansion.
|
|---|
| 541 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
|---|
| 542 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
|---|
| 543 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
|---|
| 544 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
|---|
| 545 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
|---|
| 546 | define def_inherit
|
|---|
| 547 |
|
|---|
| 548 | # Load it.
|
|---|
| 549 | ifneq ($(load_function),)
|
|---|
| 550 | loading := $(trg)
|
|---|
| 551 | $(eval $(value $(load_function)))
|
|---|
| 552 | endif
|
|---|
| 553 |
|
|---|
| 554 | src := $(strip $($(trg)_EXTENDS))
|
|---|
| 555 | ifneq ($(src),)
|
|---|
| 556 | ifndef $(trg)_EXTENDS_STATUS_
|
|---|
| 557 | $(trg)_EXTENDS_STATUS_ := 0
|
|---|
| 558 |
|
|---|
| 559 | # Load the source.
|
|---|
| 560 | ifneq ($(load_function),)
|
|---|
| 561 | loading := $(src)
|
|---|
| 562 | $(eval $(value $(load_function)))
|
|---|
| 563 | endif
|
|---|
| 564 |
|
|---|
| 565 | # less typing.
|
|---|
| 566 | src := $(src_prefix)$(src)
|
|---|
| 567 |
|
|---|
| 568 | # Recursivly process the parent (src) if it's inherting from somebody too.
|
|---|
| 569 | ifdef $(src)_EXTENDS
|
|---|
| 570 | ifneq ($($(src)_EXTENDS_STATUS_),42)
|
|---|
| 571 | # 'foreach' will create 'trg' in a new variable context hiding
|
|---|
| 572 | # out current variable. 'src' OTOH will be overwritten.
|
|---|
| 573 | #$ (warning def_inherit: recursing into $(src) from $(trg))
|
|---|
| 574 | $(foreach trg, $(src), $(eval $(value def_inherit)))
|
|---|
| 575 | src := $(src_prefix)$(strip $($(trg)_EXTENDS))
|
|---|
| 576 | endif
|
|---|
| 577 | endif
|
|---|
| 578 |
|
|---|
| 579 | # Get & check EXTENDS_BY.
|
|---|
| 580 | by = $(strip $($(trg)_EXTENDS_BY))
|
|---|
| 581 | ifeq ($(by),)
|
|---|
| 582 | by = overriding
|
|---|
| 583 | else ifn1of ($(by), overriding appending prepending)
|
|---|
| 584 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!)
|
|---|
| 585 | endif
|
|---|
| 586 |
|
|---|
| 587 | # Inherit the properties.
|
|---|
| 588 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)), $(eval $(def_inherit_one)))
|
|---|
| 589 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)), $(eval $(def_inherit_one_$(by)_now_l)))
|
|---|
| 590 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)), $(eval $(def_inherit_one_$(by)_now_r)))
|
|---|
| 591 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)), $(eval $(def_inherit_one_$(by)_deferred)))
|
|---|
| 592 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l)))
|
|---|
| 593 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r)))
|
|---|
| 594 |
|
|---|
| 595 | # Mark the target as done.
|
|---|
| 596 | $(trg)_EXTENDS_STATUS_ := 42
|
|---|
| 597 | else
|
|---|
| 598 | # Check for inheritance loops.
|
|---|
| 599 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
|---|
| 600 | $(error kBuild: Target inheritance loop! target=$(trg) $(trg)_EXTENDS_STATUS_=$($(trg)_EXTENDS_STATUS_))
|
|---|
| 601 | endif
|
|---|
| 602 | endif
|
|---|
| 603 | endif
|
|---|
| 604 |
|
|---|
| 605 | # Keyword inheritance.
|
|---|
| 606 | $(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(eval $(value def_inherit_keyword)))
|
|---|
| 607 |
|
|---|
| 608 | endef # def_inherit
|
|---|
| 609 |
|
|---|
| 610 |
|
|---|
| 611 | #
|
|---|
| 612 | # Determin all the templates that is being used and make
|
|---|
| 613 | # sure they are present before we try collect keywords.
|
|---|
| 614 | #
|
|---|
| 615 | _TEMPLATES := $(TEMPLATE)
|
|---|
| 616 | define def_templates
|
|---|
| 617 | ifdef $(target)_TEMPLATE
|
|---|
| 618 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
|---|
| 619 | $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them)
|
|---|
| 620 | endif
|
|---|
| 621 | _TEMPLATES += $($(target)_TEMPLATE)
|
|---|
| 622 | endif
|
|---|
| 623 | endef # def_templates
|
|---|
| 624 | $(foreach target, $(_ALL_TARGETS), $(eval $(def_templates)))
|
|---|
| 625 | _TEMPLATES := $(sort $(_TEMPLATES))
|
|---|
| 626 |
|
|---|
| 627 | ## Template load function.
|
|---|
| 628 | # @param loading The template name. This is prefixed.
|
|---|
| 629 | define def_templates_load_function
|
|---|
| 630 | loading := $(patsubst TEMPLATE_%,%,$(loading))
|
|---|
| 631 | ifndef TEMPLATE_$(loading)
|
|---|
| 632 | TEMPLATE_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TEMPLATE_PATHS) $(PATH_KBUILD)/templates $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
|---|
| 633 | ifneq ($(TEMPLATE_$(loading)_KMK_FILE),)
|
|---|
| 634 | $(error kBuild: Cannot find include file for the template '$(loading)'! Searched: $(KBUILD_TEMPLATE_PATHS) $(PATH_KBUILD)/templates $(KBUILD_DEFAULT_PATHS))
|
|---|
| 635 | endif
|
|---|
| 636 | include $(TEMPLATE_$(loading)_KMK_FILE)
|
|---|
| 637 | ifndef TEMPLATE_$(loading)
|
|---|
| 638 | $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!)
|
|---|
| 639 | endif
|
|---|
| 640 | endif
|
|---|
| 641 | endef # def_templates_include
|
|---|
| 642 | $(foreach loading, $(addprefix TEMPLATE_,$(_TEMPLATES)), $(eval $(value def_templates_include)))
|
|---|
| 643 |
|
|---|
| 644 |
|
|---|
| 645 | #
|
|---|
| 646 | # Determin the keywords required for correct inherting and setup keyword inheritance.
|
|---|
| 647 | #
|
|---|
| 648 | # This means walking all the lists of immediate template and targets and
|
|---|
| 649 | # pick up all the BLD_T* keywords. Since templates that are referenced
|
|---|
| 650 | # indirectly in the inheritance hierarchy, the result from this exercise
|
|---|
| 651 | # might not be 100% accurate... :-/
|
|---|
| 652 | #
|
|---|
| 653 | _BLD_TYPES := $(BUILD_TYPE)
|
|---|
| 654 | _BLD_TARGETS := $(BUILD_TARGET) $(BUILD_PLATFORMS)
|
|---|
| 655 | _BLD_ARCHES := $(BUILD_TARGET_ARCH) $(BUILD_PLATFORM_ARCH)
|
|---|
| 656 | _BLD_CPUS := $(BUILD_TARGET_CPU) $(BUILD_PLATFORM_CPU)
|
|---|
| 657 |
|
|---|
| 658 | define def_collect_bld_xyz
|
|---|
| 659 | ifdef $(src)_BLD_TYPE
|
|---|
| 660 | ifn1of ($($(src)_BLD_TYPE), $(KBUILD_BLD_TYPES))
|
|---|
| 661 | $(error kBuild: $(src)_BLD_TYPE=$($(src)_BLD_TYPE) not in KBUILD_BLD_TYPES={$(KBUILD_BLD_TYPES)}!)
|
|---|
| 662 | endif
|
|---|
| 663 | _BLD_TYPES += $($(src)_BLD_TYPE)
|
|---|
| 664 | endif
|
|---|
| 665 | ifdef $(src)_BLD_TRG
|
|---|
| 666 | ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES))
|
|---|
| 667 | $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!)
|
|---|
| 668 | endif
|
|---|
| 669 | _BLD_TARGETS += $($(src)_BLD_TRG)
|
|---|
| 670 | endif
|
|---|
| 671 | ifdef $(src)_BLD_TRG_ARCH
|
|---|
| 672 | ifn1of ($($(src)_BLD_TRG_ARCH), $(KBUILD_ARCHES))
|
|---|
| 673 | $(error kBuild: $(src)_BLD_TRG_ARCH=$($(src)_BLD_TRG_ARCH) not in KBUILD_ARCHES={$(KBUILD_ARCHES)}!)
|
|---|
| 674 | endif
|
|---|
| 675 | _BLD_ARCHES += $($(src)_BLD_TRG_ARCH)
|
|---|
| 676 | endif
|
|---|
| 677 | ifdef $(src)_BLD_TRG_CPU
|
|---|
| 678 | if1of ($($(src)_BLD_CPU), $(KBUILD_ARCHES) $(KBUILD_OSES) $(KBUILD_BLD_TYPES))
|
|---|
| 679 | $(error kBuild: $(src)_BLD_TRG_CPU=$($(src)_BLD_TRG_CPU) found in KBUILD_ARCHES, KBUILD_OSES or KBUILD_BLD_TYPES!)
|
|---|
| 680 | endif
|
|---|
| 681 | _BLD_CPUS += $($(src)_BLD_TRG_CPU)
|
|---|
| 682 | endif
|
|---|
| 683 | endef # def_collect_bld_xyz
|
|---|
| 684 | $(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS) \
|
|---|
| 685 | ,$(eval $(value def_collect_bld_xyz)))
|
|---|
| 686 |
|
|---|
| 687 | # Drop duplicate values.
|
|---|
| 688 | # WARNING! These list might not include keywords only involved in inheritance.
|
|---|
| 689 | _BLD_TYPES := $(sort $(_BLD_TYPES))
|
|---|
| 690 | _BLD_TARGETS := $(sort $(_BLD_TARGETS))
|
|---|
| 691 | _BLD_ARCHES := $(sort $(_BLD_ARCHES))
|
|---|
| 692 | _BLD_CPUS := $(sort $(_BLD_CPUS))
|
|---|
| 693 |
|
|---|
| 694 | ## Look for keywords which extends others and order them.
|
|---|
| 695 | # @param keyword
|
|---|
| 696 | # @param prefix
|
|---|
| 697 | # @param valid
|
|---|
| 698 | define def_keyword_ordering
|
|---|
| 699 | # Check for EXTENDS, fix and validate it if found.
|
|---|
| 700 | src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
|---|
| 701 | ifneq ($(src),)
|
|---|
| 702 | ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_
|
|---|
| 703 | ifn1of ($(src), $(valid))
|
|---|
| 704 | $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid)))
|
|---|
| 705 | endif
|
|---|
| 706 |
|
|---|
| 707 | # Recursivly process the parent (src).
|
|---|
| 708 | ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42)
|
|---|
| 709 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0
|
|---|
| 710 | # 'foreach' will create 'keyword' in a new variable context hiding
|
|---|
| 711 | # out current variable. 'src' OTOH will be overwritten.
|
|---|
| 712 | $(foreach keyword, $(src), $(eval $(value def_keyword_ordering)))
|
|---|
| 713 | src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
|---|
| 714 | endif
|
|---|
| 715 |
|
|---|
| 716 | # Check and strip EXTENDS_BY.
|
|---|
| 717 | by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY))
|
|---|
| 718 | ifeq ($(by),)
|
|---|
| 719 | by = overriding
|
|---|
| 720 | else ifn1of ($(by), overriding appending prepending)
|
|---|
| 721 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!)
|
|---|
| 722 | endif
|
|---|
| 723 |
|
|---|
| 724 | # Update the attributes with stripped
|
|---|
| 725 | $(prefix)_$(keyword)_EXTENDS_BY := $(by)
|
|---|
| 726 | $(prefix)_$(keyword)_EXTENDS := $(src)
|
|---|
| 727 |
|
|---|
| 728 | # Add it to the list and mark it as done.
|
|---|
| 729 | _KEYWORDS_EXTENDS += $(keyword)
|
|---|
| 730 | _KEYWORDS_PREFIX += $(prefix)
|
|---|
| 731 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42
|
|---|
| 732 | else
|
|---|
| 733 | # Check for inheritance loops.
|
|---|
| 734 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
|---|
| 735 | $(error kBuild: Keyword inheritance loop! keyword=$(keyword) $(prefix)_$(keyword)_EXTENDS_STATUS_=$($(prefix)_$(keyword)_EXTENDS_STATUS_))
|
|---|
| 736 | endif
|
|---|
| 737 | endif
|
|---|
| 738 | else
|
|---|
| 739 | # Add it to the ordered list and mark it as done.
|
|---|
| 740 | _KEYWORDS_ORDERED += $(keyword)
|
|---|
| 741 | $(prefix)_$(src)_EXTENDS_STATUS_ := 42
|
|---|
| 742 | endif
|
|---|
| 743 | endef # def_keyword_ordering
|
|---|
| 744 |
|
|---|
| 745 | # Look for keywords which extends others and their parents, and from this
|
|---|
| 746 | # construct two lists.
|
|---|
| 747 | _KEYWORDS_ORDERED :=
|
|---|
| 748 | _KEYWORDS_EXTENDS :=
|
|---|
| 749 | _KEYWORDS_PREFIX :=
|
|---|
| 750 |
|
|---|
| 751 | prefix := BLD_TYPE
|
|---|
| 752 | valid := $(KBUILD_BLD_TYPES)
|
|---|
| 753 | $(foreach keyword, $(_BLD_TYPES) , $(eval $(value def_keyword_ordering)))
|
|---|
| 754 |
|
|---|
| 755 | prefix := BLD_TRG
|
|---|
| 756 | valid := $(KBUILD_OSES)
|
|---|
| 757 | $(foreach keyword, $(_BLD_TARGETS), $(eval $(value def_keyword_ordering)))
|
|---|
| 758 |
|
|---|
| 759 | prefix := BLD_ARCH
|
|---|
| 760 | valid := $(KBUILD_ARCHES)
|
|---|
| 761 | $(foreach keyword, $(_BLD_ARCHES) , $(eval $(value def_keyword_ordering)))
|
|---|
| 762 |
|
|---|
| 763 | prefix := BLD_CPU
|
|---|
| 764 | valid := $(KBUILD_CPUS)
|
|---|
| 765 | $(foreach keyword, $(_BLD_CPUS) , $(eval $(value def_keyword_ordering)))
|
|---|
| 766 |
|
|---|
| 767 | ## @todo Inherit bld_trg.bld_arch for too?
|
|---|
| 768 |
|
|---|
| 769 | # Construct all the possible keywords.
|
|---|
| 770 | _KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \
|
|---|
| 771 | $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
|
|---|
| 772 |
|
|---|
| 773 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 774 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 775 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done keywords)
|
|---|
| 776 | $(info stat: $(make-stats ))
|
|---|
| 777 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 778 | endif
|
|---|
| 779 |
|
|---|
| 780 |
|
|---|
| 781 | #
|
|---|
| 782 | # Target inheritance.
|
|---|
| 783 | #
|
|---|
| 784 | # This has to be done on a per target list basis as to avoid adding
|
|---|
| 785 | # incorrect properties that will wast memory, time, and may confuse
|
|---|
| 786 | # later strictness checks. This also has to be done *before* templates
|
|---|
| 787 | # are applied to the targets. Since we're doing that part rather
|
|---|
| 788 | # early on, the target inheritance feature is a bit restricted at
|
|---|
| 789 | # the moment. However, this will be addressed in a little(?) while.
|
|---|
| 790 | #
|
|---|
| 791 |
|
|---|
| 792 | src_prefix :=
|
|---|
| 793 | load_function :=
|
|---|
| 794 | properties_deferred_l :=
|
|---|
| 795 | properties_deferred_r :=
|
|---|
| 796 |
|
|---|
| 797 | # Fetches.
|
|---|
| 798 | properties := $(PROPS_FETCHES_SINGLE)
|
|---|
| 799 | properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L)
|
|---|
| 800 | properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R)
|
|---|
| 801 | properties_deferred := $(PROPS_FETCHES_DEFERRED)
|
|---|
| 802 | $(foreach trg, $(_ALL_FETCHES),$(eval $(value def_inherit)))
|
|---|
| 803 |
|
|---|
| 804 | ## Patches. - not implemented yet.
|
|---|
| 805 | #properties := $(PROPS_PATCHES_SINGLE)
|
|---|
| 806 | #properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L)
|
|---|
| 807 | #properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R)
|
|---|
| 808 | #properties_deferred := $(PROPS_PATCHES_DEFERRED)
|
|---|
| 809 | #$(foreach trg, $(_ALL_PATCHES),$(eval $(value def_inherit)))
|
|---|
| 810 |
|
|---|
| 811 | # Programs and build programs.
|
|---|
| 812 | properties := $(PROPS_PROGRAMS_SINGLE)
|
|---|
| 813 | properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L)
|
|---|
| 814 | properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R)
|
|---|
| 815 | properties_deferred := $(PROPS_PROGRAMS_DEFERRED)
|
|---|
| 816 | $(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(eval $(value def_inherit)))
|
|---|
| 817 |
|
|---|
| 818 | # Libraries and import libraries.
|
|---|
| 819 | properties := $(PROPS_LIBRARIES_SINGLE)
|
|---|
| 820 | properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L)
|
|---|
| 821 | properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R)
|
|---|
| 822 | properties_deferred := $(PROPS_LIBRARIES_DEFERRED)
|
|---|
| 823 | if1of ($(BUILD_TARGET), nt os2 win)
|
|---|
| 824 | $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(eval $(value def_inherit)))
|
|---|
| 825 | else
|
|---|
| 826 | $(foreach trg, $(_ALL_LIBRARIES),$(eval $(value def_inherit)))
|
|---|
| 827 | endif
|
|---|
| 828 |
|
|---|
| 829 | # DLLs.
|
|---|
| 830 | properties := $(PROPS_DLLS_SINGLE)
|
|---|
| 831 | properties_now_l := $(PROPS_DLLS_ACCUMULATE_L)
|
|---|
| 832 | properties_now_r := $(PROPS_DLLS_ACCUMULATE_R)
|
|---|
| 833 | properties_deferred := $(PROPS_DLLS_DEFERRED)
|
|---|
| 834 | if1of ($(BUILD_TARGET), nt os2 win)
|
|---|
| 835 | $(foreach trg, $(_ALL_DLLS),$(eval $(value def_inherit)))
|
|---|
| 836 | else
|
|---|
| 837 | $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(eval $(value def_inherit)))
|
|---|
| 838 | endif
|
|---|
| 839 |
|
|---|
| 840 | # System modules.
|
|---|
| 841 | properties := $(PROPS_SYSMODS_SINGLE)
|
|---|
| 842 | properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L)
|
|---|
| 843 | properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R)
|
|---|
| 844 | properties_deferred := $(PROPS_SYSMODS_DEFERRED)
|
|---|
| 845 | $(foreach trg, $(_ALL_SYSMODS),$(eval $(value def_inherit)))
|
|---|
| 846 |
|
|---|
| 847 | # Installs.
|
|---|
| 848 | properties := $(PROPS_INSTALLS_SINGLE)
|
|---|
| 849 | properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L)
|
|---|
| 850 | properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R)
|
|---|
| 851 | properties_deferred := $(PROPS_INSTALLS_DEFERRED)
|
|---|
| 852 | $(foreach trg, $(_ALL_INSTALLS),$(eval $(value def_inherit)))
|
|---|
| 853 |
|
|---|
| 854 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 855 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 856 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done target inheritance)
|
|---|
| 857 | $(info stat: $(make-stats ))
|
|---|
| 858 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 859 | endif
|
|---|
| 860 |
|
|---|
| 861 |
|
|---|
| 862 | #
|
|---|
| 863 | # Template Inheritance.
|
|---|
| 864 | #
|
|---|
| 865 | # This is much the same as with target inheritance, except we cannot
|
|---|
| 866 | # restrict the properties involved since we haven't got a clue which
|
|---|
| 867 | # target platforms/archs are using them. But, we can drop the instance
|
|---|
| 868 | # expansion we're doing for targets since there won't be any more
|
|---|
| 869 | # changes to either the source nor the target templates beyond this
|
|---|
| 870 | # exercise.
|
|---|
| 871 | #
|
|---|
| 872 |
|
|---|
| 873 | src_prefix := TEMPLATE_
|
|---|
| 874 | load_function := def_templates_load_function
|
|---|
| 875 | properties :=
|
|---|
| 876 | properties_now_l :=
|
|---|
| 877 | properties_now_r :=
|
|---|
| 878 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
|---|
| 879 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
|---|
| 880 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
|---|
| 881 | $(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(eval $(value def_inherit)))
|
|---|
| 882 |
|
|---|
| 883 | # done inheriting.
|
|---|
| 884 | src_prefix :=
|
|---|
| 885 | load_function :=
|
|---|
| 886 | properties :=
|
|---|
| 887 | properties_now_l :=
|
|---|
| 888 | properties_now_r :=
|
|---|
| 889 | properties_deferred :=
|
|---|
| 890 | properties_deferred_l :=
|
|---|
| 891 | properties_deferred_r :=
|
|---|
| 892 |
|
|---|
| 893 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 894 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 895 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done template inheritance)
|
|---|
| 896 | $(info stat: $(make-stats ))
|
|---|
| 897 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 898 | endif
|
|---|
| 899 |
|
|---|
| 900 |
|
|---|
| 901 |
|
|---|
| 902 |
|
|---|
| 903 | #
|
|---|
| 904 | # Template/Target Expansion.
|
|---|
| 905 | #
|
|---|
| 906 | # Extend all targets with the values from the template. Doing this up front
|
|---|
| 907 | # allows more generic code and less mess down in the pass 2 target handling.
|
|---|
| 908 | # However it does eat a good deal of memory.
|
|---|
| 909 | #
|
|---|
| 910 |
|
|---|
| 911 | ## Inherit one template property in a non-accumulative manner.
|
|---|
| 912 | # @param $(prop) Property name
|
|---|
| 913 | # @param $(target) Target name
|
|---|
| 914 | # @todo fix the precedence order for some properties.
|
|---|
| 915 | define def_inherit_template_one
|
|---|
| 916 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
|---|
| 917 | ifndef $(target)_$(prop)
|
|---|
| 918 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
|---|
| 919 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
|---|
| 920 | endif
|
|---|
| 921 | endif
|
|---|
| 922 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
|---|
| 923 | ifndef $(target)_$(prop).$(bld_trg)
|
|---|
| 924 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
|---|
| 925 | $(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
|---|
| 926 | endif
|
|---|
| 927 | endif
|
|---|
| 928 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
|---|
| 929 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
|---|
| 930 | #$ (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))
|
|---|
| 931 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
|---|
| 932 | endif
|
|---|
| 933 | endif
|
|---|
| 934 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
|---|
| 935 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
|---|
| 936 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
|---|
| 937 | $(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
|---|
| 938 | endif
|
|---|
| 939 | endif
|
|---|
| 940 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
|---|
| 941 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
|---|
| 942 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
|---|
| 943 | $(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
|---|
| 944 | endif
|
|---|
| 945 | endif
|
|---|
| 946 | endef
|
|---|
| 947 |
|
|---|
| 948 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
|---|
| 949 | # @param 1: $(prop) Property name
|
|---|
| 950 | # @param 2: $(target) Target name
|
|---|
| 951 | # @todo fix the precedence order for some properties.
|
|---|
| 952 | # @remark this define relies on double evaluation
|
|---|
| 953 | define def_inherit_template_one_deferred
|
|---|
| 954 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
|---|
| 955 | ifndef $(target)_$(prop)
|
|---|
| 956 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
|---|
| 957 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
|---|
| 958 | endif
|
|---|
| 959 | endif
|
|---|
| 960 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
|---|
| 961 | ifndef $(target)_$(prop).$(bld_trg)
|
|---|
| 962 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
|---|
| 963 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
|---|
| 964 | endif
|
|---|
| 965 | endif
|
|---|
| 966 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
|---|
| 967 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
|---|
| 968 | #$ (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))
|
|---|
| 969 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
|---|
| 970 | endif
|
|---|
| 971 | endif
|
|---|
| 972 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
|---|
| 973 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
|---|
| 974 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
|---|
| 975 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
|---|
| 976 | endif
|
|---|
| 977 | endif
|
|---|
| 978 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
|---|
| 979 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
|---|
| 980 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
|---|
| 981 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
|---|
| 982 | endif
|
|---|
| 983 | endif
|
|---|
| 984 | endef
|
|---|
| 985 |
|
|---|
| 986 | ## Inherit one acculumlative template property where the 'most significant' items are at the left end.
|
|---|
| 987 | # @param $(prop) Property name
|
|---|
| 988 | # @param $(target) Target name
|
|---|
| 989 | define def_inherit_template_one_accumulate_l
|
|---|
| 990 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
|---|
| 991 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
|---|
| 992 | $(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
|---|
| 993 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
|---|
| 994 | endif
|
|---|
| 995 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
|---|
| 996 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
|---|
| 997 | $(target)_$(prop).$(BUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
|---|
| 998 | endif
|
|---|
| 999 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
|---|
| 1000 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
|---|
| 1001 | $(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
|---|
| 1002 | endif
|
|---|
| 1003 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
|---|
| 1004 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
|---|
| 1005 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
|---|
| 1006 | endif
|
|---|
| 1007 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
|---|
| 1008 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
|---|
| 1009 | $(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
|---|
| 1010 | endif
|
|---|
| 1011 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
|---|
| 1012 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
|---|
| 1013 | $(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
|---|
| 1014 | endif
|
|---|
| 1015 | endef
|
|---|
| 1016 |
|
|---|
| 1017 | ## Inherit one acculumlative template property where the 'most significant' items are at the right end.
|
|---|
| 1018 | # @param $(prop) Property name
|
|---|
| 1019 | # @param $(target) Target name
|
|---|
| 1020 | define def_inherit_template_one_accumulate_r
|
|---|
| 1021 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
|---|
| 1022 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
|---|
| 1023 | $(target)_$(prop) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
|---|
| 1024 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
|---|
| 1025 | endif
|
|---|
| 1026 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
|---|
| 1027 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
|---|
| 1028 | $(target)_$(prop).$(BUILD_TYPE) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
|---|
| 1029 | endif
|
|---|
| 1030 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
|---|
| 1031 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
|---|
| 1032 | $(target)_$(prop).$(bld_trg) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
|---|
| 1033 | endif
|
|---|
| 1034 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
|---|
| 1035 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
|---|
| 1036 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
|---|
| 1037 | endif
|
|---|
| 1038 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
|---|
| 1039 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
|---|
| 1040 | $(target)_$(prop).$(bld_trg_cpu) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
|---|
| 1041 | endif
|
|---|
| 1042 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
|---|
| 1043 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
|---|
| 1044 | $(target)_$(prop).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
|---|
| 1045 | endif
|
|---|
| 1046 | endef
|
|---|
| 1047 |
|
|---|
| 1048 |
|
|---|
| 1049 | ## Inherit template properties for on target.
|
|---|
| 1050 | # @param $(target) Target name.
|
|---|
| 1051 | define def_inherit_template
|
|---|
| 1052 | # sanity check.
|
|---|
| 1053 | ifdef _$(target)_ALREADY_PROCESSED
|
|---|
| 1054 | $(error kBuild: The target $(target) appears more than once in the target lists! Please correct the makefile(s))
|
|---|
| 1055 | endif
|
|---|
| 1056 | _$(target)_ALREADY_PROCESSED := 1
|
|---|
| 1057 |
|
|---|
| 1058 | # Inherit any default template.
|
|---|
| 1059 | ifdef TEMPLATE
|
|---|
| 1060 | ifeq ($($(target)_TEMPLATE),)
|
|---|
| 1061 | $(eval $(target)_TEMPLATE:=$(TEMPLATE))
|
|---|
| 1062 | endif
|
|---|
| 1063 | endif
|
|---|
| 1064 | # Expand the template if specified.
|
|---|
| 1065 | ifneq ($($(target)_TEMPLATE),)
|
|---|
| 1066 | $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
|
|---|
| 1067 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
|---|
| 1068 | $(foreach prop,$(PROPS_ACCUMULATE_L),$(eval $(def_inherit_template_one_accumulate_l))) # += works fine without value
|
|---|
| 1069 | $(foreach prop,$(PROPS_ACCUMULATE_R),$(eval $(def_inherit_template_one_accumulate_r))) # use <= (kmk addition)
|
|---|
| 1070 | endif
|
|---|
| 1071 | endef
|
|---|
| 1072 |
|
|---|
| 1073 | # Inherit template properties
|
|---|
| 1074 | bld_trg := $(BUILD_TARGET)
|
|---|
| 1075 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
|---|
| 1076 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
|---|
| 1077 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(value def_inherit_template)))
|
|---|
| 1078 |
|
|---|
| 1079 | bld_trg := $(BUILD_PLATFORM)
|
|---|
| 1080 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
|---|
| 1081 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
|---|
| 1082 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(value def_inherit_template)))
|
|---|
| 1083 |
|
|---|
| 1084 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 1085 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 1086 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done template/target expansion)
|
|---|
| 1087 | $(info stat: $(make-stats ))
|
|---|
| 1088 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 1089 | endif
|
|---|
| 1090 |
|
|---|
| 1091 |
|
|---|
| 1092 | #
|
|---|
| 1093 | # Include tools & sdks
|
|---|
| 1094 | #
|
|---|
| 1095 | # The first part of this exercise is to figure out which TOOLS and SDKS
|
|---|
| 1096 | # that should be included.
|
|---|
| 1097 | #
|
|---|
| 1098 | _TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET_ARCH)) $(TOOL.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
|---|
| 1099 | $(TOOL.$(BUILD_PLATFORM)) $(TOOL.$(BUILD_PLATFORM_ARCH)) $(TOOL.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
|---|
| 1100 | $(TOOL)
|
|---|
| 1101 | _SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_TARGET_ARCH)) $(SDKS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
|---|
| 1102 | $(SDKS.$(BUILD_PLATFORM)) $(SDKS.$(BUILD_PLATFORM_ARCH)) $(SDKS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
|---|
| 1103 | $(SDKS.$(BUILD_TYPE)) \
|
|---|
| 1104 | $(SDKS)
|
|---|
| 1105 | define def_tools_sdks_target_source
|
|---|
| 1106 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
|---|
| 1107 | $($(source)_$(prop).$(_bld_trg)) \
|
|---|
| 1108 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
|---|
| 1109 | $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
|---|
| 1110 | $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
|---|
| 1111 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
|---|
| 1112 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
|---|
| 1113 | $($(source)_$(prop)) \
|
|---|
| 1114 | $($(target)_$(source)_$(prop))))
|
|---|
| 1115 | $(eval _SDKS += \
|
|---|
| 1116 | $($(source)_SDKS.$(_bld_trg)) \
|
|---|
| 1117 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
|---|
| 1118 | $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
|---|
| 1119 | $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
|---|
| 1120 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
|---|
| 1121 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
|---|
| 1122 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
|---|
| 1123 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
|---|
| 1124 | $($(source)_SDKS) \
|
|---|
| 1125 | $($(target)_$(source)_SDKS))
|
|---|
| 1126 | endef # def_tools_sdks_target_source
|
|---|
| 1127 |
|
|---|
| 1128 | define def_tools_sdks_target
|
|---|
| 1129 | _bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
|---|
| 1130 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
|---|
| 1131 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
|---|
| 1132 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
|---|
| 1133 |
|
|---|
| 1134 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
|---|
| 1135 | $($(target)_$(prop).$(_bld_trg)) \
|
|---|
| 1136 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
|---|
| 1137 | $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
|---|
| 1138 | $($(target)_$(prop))))
|
|---|
| 1139 | $(eval _SDKS += \
|
|---|
| 1140 | $($(target)_SDKS.$(_bld_trg)) \
|
|---|
| 1141 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
|---|
| 1142 | $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
|---|
| 1143 | $($(target)_SDKS))
|
|---|
| 1144 | $(foreach source, \
|
|---|
| 1145 | $($(target)_SOURCES.$(_bld_trg)) \
|
|---|
| 1146 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
|---|
| 1147 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
|---|
| 1148 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
|---|
| 1149 | $($(target)_SOURCES.$(_bld_type)) \
|
|---|
| 1150 | $($(target)_SOURCES) \
|
|---|
| 1151 | , $(eval $(value def_tools_sdks_target_source)))
|
|---|
| 1152 | endef # def_tools_sdks_target
|
|---|
| 1153 |
|
|---|
| 1154 | define def_tools_srcname_target
|
|---|
| 1155 | _bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
|---|
| 1156 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
|---|
| 1157 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
|---|
| 1158 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
|---|
| 1159 |
|
|---|
| 1160 | $(foreach source, $(notdir\
|
|---|
| 1161 | $($(target)_SOURCES.$(_bld_trg)) \
|
|---|
| 1162 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
|---|
| 1163 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
|---|
| 1164 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
|---|
| 1165 | $($(target)_SOURCES.$(_bld_type)) \
|
|---|
| 1166 | $($(target)_SOURCES) \
|
|---|
| 1167 | ), $(eval $(value def_tools_sdks_target_source)))
|
|---|
| 1168 | endef # def_tools_srcname_target
|
|---|
| 1169 |
|
|---|
| 1170 | bld_trg := $(BUILD_TARGET)
|
|---|
| 1171 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
|---|
| 1172 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
|---|
| 1173 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(eval $(value def_tools_sdks_target)))
|
|---|
| 1174 | $(foreach target, $(_ALL_SRCNAME_TARGETS), $(eval $(value def_tools_srcname_target)))
|
|---|
| 1175 |
|
|---|
| 1176 | bld_trg := $(BUILD_PLATFORM)
|
|---|
| 1177 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
|---|
| 1178 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
|---|
| 1179 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS), $(eval $(value def_tools_sdks_target)))
|
|---|
| 1180 |
|
|---|
| 1181 | _TOOLS := $(sort $(_TOOLS))
|
|---|
| 1182 | _SDKS := $(sort $(_SDKS))
|
|---|
| 1183 |
|
|---|
| 1184 | ## Tool load function.
|
|---|
| 1185 | # @param loading The tool name
|
|---|
| 1186 | define def_tools_load_function
|
|---|
| 1187 | ifndef TOOL_$(loading)
|
|---|
| 1188 | TOOL_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TOOL_PATHS) $(PATH_KBUILD)/tools $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
|---|
| 1189 | ifeq ($(TOOL_$(loading)_KMK_FILE),)
|
|---|
| 1190 | $(error kBuild: Cannot find include file for the tool '$(loading)'! Searched: $(KBUILD_TOOL_PATHS) $(PATH_KBUILD)/tools $(KBUILD_DEFAULT_PATHS))
|
|---|
| 1191 | endif
|
|---|
| 1192 | include $(TOOL_$(loading)_KMK_FILE)
|
|---|
| 1193 | ifndef TOOL_$(loading)
|
|---|
| 1194 | $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!)
|
|---|
| 1195 | endif
|
|---|
| 1196 | endif
|
|---|
| 1197 | endef # def_tools_include
|
|---|
| 1198 |
|
|---|
| 1199 | ## SDK load function.
|
|---|
| 1200 | # @param loading The tool name
|
|---|
| 1201 | define def_sdk_load_function
|
|---|
| 1202 | ifndef SDK_$(loading)
|
|---|
| 1203 | SDK_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_SDK_PATHS) $(PATH_KBUILD)/sdks $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
|---|
| 1204 | ifeq ($(SDK_$(loading)_KMK_FILE),)
|
|---|
| 1205 | $(error kBuild: Cannot find include file for the SDK '$(loading)'! Searched: $(KBUILD_SDK_PATHS) $(PATH_KBUILD)/sdks $(KBUILD_DEFAULT_PATHS))
|
|---|
| 1206 | endif
|
|---|
| 1207 | include $(SDK_$(loading)_KMK_FILE)
|
|---|
| 1208 | ifndef SDK_$(loading)
|
|---|
| 1209 | $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!)
|
|---|
| 1210 | endif
|
|---|
| 1211 | endif
|
|---|
| 1212 | endef # def_sdk_load_function
|
|---|
| 1213 |
|
|---|
| 1214 |
|
|---|
| 1215 | properties :=
|
|---|
| 1216 | properties_now_l :=
|
|---|
| 1217 | properties_now_r :=
|
|---|
| 1218 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
|---|
| 1219 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
|---|
| 1220 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
|---|
| 1221 |
|
|---|
| 1222 | src_prefix := TOOL_
|
|---|
| 1223 | load_function := def_tools_load_function
|
|---|
| 1224 | $(foreach trg, $(_TOOLS), $(eval $(value def_inherit)))
|
|---|
| 1225 |
|
|---|
| 1226 | src_prefix := SDK_
|
|---|
| 1227 | load_function := def_sdk_load_function
|
|---|
| 1228 | $(foreach trg, $(_SDKS) , $(eval $(value def_inherit)))
|
|---|
| 1229 |
|
|---|
| 1230 | # done inheriting.
|
|---|
| 1231 | src_prefix :=
|
|---|
| 1232 | load_function :=
|
|---|
| 1233 | properties :=
|
|---|
| 1234 | properties_now_l :=
|
|---|
| 1235 | properties_now_r :=
|
|---|
| 1236 | properties_deferred :=
|
|---|
| 1237 | properties_deferred_l :=
|
|---|
| 1238 | properties_deferred_r :=
|
|---|
| 1239 |
|
|---|
| 1240 |
|
|---|
| 1241 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 1242 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 1243 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done tools and sdks)
|
|---|
| 1244 | $(info stat: $(make-stats ))
|
|---|
| 1245 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 1246 | endif
|
|---|
| 1247 |
|
|---|
| 1248 |
|
|---|
| 1249 |
|
|---|
| 1250 | #
|
|---|
| 1251 | #
|
|---|
| 1252 | # Target lists - Pass 1
|
|---|
| 1253 | #
|
|---|
| 1254 | # This pass is for defining variables that might be referenced in
|
|---|
| 1255 | # properties of other targets.
|
|---|
| 1256 | #
|
|---|
| 1257 | #
|
|---|
| 1258 |
|
|---|
| 1259 | # Don't do anything for fetch targets (yet).
|
|---|
| 1260 |
|
|---|
| 1261 | ##
|
|---|
| 1262 | # Link prolog for Pass 1.
|
|---|
| 1263 | #
|
|---|
| 1264 | # @param $(target) Normalized target name.
|
|---|
| 1265 | # @param $(EXT) EXE,DLL,SYS,LIB.
|
|---|
| 1266 | # @param $(EXTPRE) HOST or nothing.
|
|---|
| 1267 | # @param $(definst) The default _INST value.
|
|---|
| 1268 | # @param $(tool_prefix) LD or AR.
|
|---|
| 1269 | # @param $(bld_trg_base_var) TARGET or PLATFORM.
|
|---|
| 1270 | define def_pass1_link_common
|
|---|
| 1271 |
|
|---|
| 1272 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
|---|
| 1273 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
|---|
| 1274 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
|---|
| 1275 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
|---|
| 1276 |
|
|---|
| 1277 | tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
|
|---|
| 1278 | name := $(firstword\
|
|---|
| 1279 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 1280 | $($(target)_NAME.$(bld_trg_arch))\
|
|---|
| 1281 | $($(target)_NAME.$(bld_trg))\
|
|---|
| 1282 | $($(target)_NAME.$(bld_type))\
|
|---|
| 1283 | $($(target)_NAME)\
|
|---|
| 1284 | $(target))
|
|---|
| 1285 | outbase := $(call TARGET_BASE,$(name),$(target))
|
|---|
| 1286 | ifndef PATH_$(target)
|
|---|
| 1287 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
|---|
| 1288 | else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
|---|
| 1289 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
|---|
| 1290 | endif
|
|---|
| 1291 | ifeq ($(tool_prefix),AR) ## @todo fix this mess!
|
|---|
| 1292 | suff := $(firstword\
|
|---|
| 1293 | $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 1294 | $($(target)_$(EXT)SUFF.$(bld_trg))\
|
|---|
| 1295 | $($(target)_$(EXT)SUFF)\
|
|---|
| 1296 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 1297 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
|
|---|
| 1298 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
|
|---|
| 1299 | $(SUFF_LIB))
|
|---|
| 1300 | else
|
|---|
| 1301 | suff := $(firstword \
|
|---|
| 1302 | $($(target)_$(EXT)SUFF) \
|
|---|
| 1303 | $($(target)_$(EXT)SUFF) \
|
|---|
| 1304 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF) \
|
|---|
| 1305 | $($(EXTPRE)SUFF_$(EXT)))
|
|---|
| 1306 | endif
|
|---|
| 1307 | out := $(outbase)$(suff)
|
|---|
| 1308 |
|
|---|
| 1309 | # TARGET_*
|
|---|
| 1310 | TARGET_$(target) := $(out)
|
|---|
| 1311 |
|
|---|
| 1312 | # INSTARGET_*
|
|---|
| 1313 | ifndef $(target)_NOINST
|
|---|
| 1314 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
|---|
| 1315 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
|---|
| 1316 |
|
|---|
| 1317 | else # NOINST
|
|---|
| 1318 | INSTARGET_$(target) :=
|
|---|
| 1319 | endif # NOINST
|
|---|
| 1320 |
|
|---|
| 1321 | endef
|
|---|
| 1322 |
|
|---|
| 1323 |
|
|---|
| 1324 | #
|
|---|
| 1325 | # BLDPROGS (Pass 1)
|
|---|
| 1326 | #
|
|---|
| 1327 | define def_pass1_bldprog
|
|---|
| 1328 | # set NOINST if not forced installation before doing the usual stuff.
|
|---|
| 1329 | ifndef $(target)_INST
|
|---|
| 1330 | $(target)_NOINST := 1
|
|---|
| 1331 | endif
|
|---|
| 1332 | $(eval $(value def_pass1_link_common))
|
|---|
| 1333 | endef
|
|---|
| 1334 |
|
|---|
| 1335 | EXT := EXE
|
|---|
| 1336 | EXTPRE := HOST
|
|---|
| 1337 | definst := $(PATH_BIN)
|
|---|
| 1338 | tool_prefix := LD
|
|---|
| 1339 | bld_trg_base_var := PLATFORM
|
|---|
| 1340 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), \
|
|---|
| 1341 | $(eval $(value def_pass1_bldprog)))
|
|---|
| 1342 |
|
|---|
| 1343 |
|
|---|
| 1344 | #
|
|---|
| 1345 | # LIBRARIES (Pass 1)
|
|---|
| 1346 | #
|
|---|
| 1347 | EXT := LIB
|
|---|
| 1348 | EXTPRE :=
|
|---|
| 1349 | definst := $(PATH_LIB)
|
|---|
| 1350 | tool_prefix := AR
|
|---|
| 1351 | bld_trg_base_var := TARGET
|
|---|
| 1352 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1353 | $(eval $(value def_pass1_link_common)))
|
|---|
| 1354 |
|
|---|
| 1355 |
|
|---|
| 1356 | #
|
|---|
| 1357 | # DLLS (Pass 1)
|
|---|
| 1358 | #
|
|---|
| 1359 | EXT := DLL
|
|---|
| 1360 | EXTPRE :=
|
|---|
| 1361 | definst := $(PATH_DLL)
|
|---|
| 1362 | tool_prefix := LD
|
|---|
| 1363 | bld_trg_base_var := TARGET
|
|---|
| 1364 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1365 | $(eval $(value def_pass1_link_common)))
|
|---|
| 1366 |
|
|---|
| 1367 |
|
|---|
| 1368 | #
|
|---|
| 1369 | # IMPORT LIBRARIES (Pass 1)
|
|---|
| 1370 | #
|
|---|
| 1371 | # - On OS/2 and windows these are libraries.
|
|---|
| 1372 | # - On other platforms they are fake DLLs.
|
|---|
| 1373 | #
|
|---|
| 1374 | if1of ($(BUILD_TARGET), nt os2 win win64 win32)
|
|---|
| 1375 | EXT := LIB
|
|---|
| 1376 | EXTPRE :=
|
|---|
| 1377 | definst := $(PATH_LIB)
|
|---|
| 1378 | tool_prefix := AR
|
|---|
| 1379 | bld_trg_base_var := TARGET
|
|---|
| 1380 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1381 | $(eval $(value def_pass1_link_common)))
|
|---|
| 1382 | else
|
|---|
| 1383 | EXT := DLL
|
|---|
| 1384 | EXTPRE :=
|
|---|
| 1385 | definst := $(PATH_DLL)
|
|---|
| 1386 | tool_prefix := LD
|
|---|
| 1387 | bld_trg_base_var := TARGET
|
|---|
| 1388 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1389 | $(eval $(value def_pass1_link_common)))
|
|---|
| 1390 | endif
|
|---|
| 1391 |
|
|---|
| 1392 |
|
|---|
| 1393 | #
|
|---|
| 1394 | # PROGRAMS (Pass 1)
|
|---|
| 1395 | #
|
|---|
| 1396 | EXT := EXE
|
|---|
| 1397 | EXTPRE :=
|
|---|
| 1398 | definst := $(PATH_BIN)
|
|---|
| 1399 | tool_prefix := LD
|
|---|
| 1400 | bld_trg_base_var := TARGET
|
|---|
| 1401 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1402 | $(eval $(value def_pass1_link_common)))
|
|---|
| 1403 |
|
|---|
| 1404 |
|
|---|
| 1405 | #
|
|---|
| 1406 | # SYSMODS (Pass 1)
|
|---|
| 1407 | #
|
|---|
| 1408 | EXT := SYS
|
|---|
| 1409 | EXTPRE :=
|
|---|
| 1410 | definst := $(PATH_SYS)
|
|---|
| 1411 | tool_prefix := LD
|
|---|
| 1412 | bld_trg_base_var := TARGET
|
|---|
| 1413 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1414 | $(eval $(value def_pass1_link_common)))
|
|---|
| 1415 |
|
|---|
| 1416 |
|
|---|
| 1417 | #
|
|---|
| 1418 | # INSTALLS (Pass 1)
|
|---|
| 1419 | # Note! INSTARGET_* for INSTALLS aren't available until later.
|
|---|
| 1420 | #
|
|---|
| 1421 | define def_pass1_install
|
|---|
| 1422 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
|---|
| 1423 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
|---|
| 1424 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
|---|
| 1425 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
|---|
| 1426 | # TARGET_*
|
|---|
| 1427 | TARGET_$(target) := $(PATH_TARGET)/$(target).ins
|
|---|
| 1428 | # INSTARGET_ later.
|
|---|
| 1429 | endef
|
|---|
| 1430 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1431 | $(eval $(value def_pass1_install)))
|
|---|
| 1432 |
|
|---|
| 1433 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 1434 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 1435 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done pass 1)
|
|---|
| 1436 | $(info stat: $(make-stats ))
|
|---|
| 1437 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 1438 | endif
|
|---|
| 1439 |
|
|---|
| 1440 |
|
|---|
| 1441 |
|
|---|
| 1442 |
|
|---|
| 1443 | #
|
|---|
| 1444 | #
|
|---|
| 1445 | # Target lists - Pass 2
|
|---|
| 1446 | #
|
|---|
| 1447 | #
|
|---|
| 1448 |
|
|---|
| 1449 |
|
|---|
| 1450 | ## @page pg_fetches Fetching Tools, Sources and Similar.
|
|---|
| 1451 | #
|
|---|
| 1452 | # The targets listed in the the FETCHES target list have the following attributes:
|
|---|
| 1453 | # SOURCES
|
|---|
| 1454 | # INST
|
|---|
| 1455 | # FETCHTOOL
|
|---|
| 1456 | # FETCHFLAGS
|
|---|
| 1457 | # FETCHDIR
|
|---|
| 1458 | # UNPACKTOOL
|
|---|
| 1459 | # UNPACKFLAGS
|
|---|
| 1460 | #
|
|---|
| 1461 | # As usual the target name is an alias for 'creating' the target. Other
|
|---|
| 1462 | # aliases are:
|
|---|
| 1463 | # pass_fetches
|
|---|
| 1464 | # fetch
|
|---|
| 1465 | # unfetch
|
|---|
| 1466 | # download
|
|---|
| 1467 | # unpack
|
|---|
| 1468 | #
|
|---|
| 1469 | # @remark
|
|---|
| 1470 | #
|
|---|
| 1471 | # This is a little bit complex because we must guarantee that if a source file
|
|---|
| 1472 | # changes only sligtly we must refetch it and to a proper unpacking of it. It
|
|---|
| 1473 | # is also a desire that fetched archives and unpacked files can be deleted to
|
|---|
| 1474 | # save space.
|
|---|
| 1475 | #
|
|---|
| 1476 | # Thus, we must be able to cleanup what we've unpacked should any of the
|
|---|
| 1477 | # sources be removed. We do this by maintaining a file listing the files
|
|---|
| 1478 | # and directories that was unpacked. This operation is named 'unfetch'.
|
|---|
| 1479 | #
|
|---|
| 1480 | # We make use of the SIZE and MD5 attributes for each of the sources to
|
|---|
| 1481 | # create a digest that is stored in the primary target file. Subsequent
|
|---|
| 1482 | # runswill compare their digest with it to decide if a refetch is required.
|
|---|
| 1483 | # When a refetch is found necessary, an 'unfetch' is performed first to
|
|---|
| 1484 | # clean out old files and directores. Note even changes in source order
|
|---|
| 1485 | # will cause a refetch due to the way the digest is constructed and
|
|---|
| 1486 | # evaluated.
|
|---|
| 1487 | #
|
|---|
| 1488 | # By not depending directly on the archives (nor on any unpacked files)
|
|---|
| 1489 | # but on a goal made up from the archive name, size and md5, we allow
|
|---|
| 1490 | # the user to delete the archives. Naturally, this means we'll have to
|
|---|
| 1491 | # check and fetch missing archives before attempting to unpack them.
|
|---|
| 1492 | #
|
|---|
| 1493 | # @remark
|
|---|
| 1494 | #
|
|---|
| 1495 | # This feature will *NOT* work correctly with vanilla GNU make becuase
|
|---|
| 1496 | # it makes use of includedep to avoid too many unnecessary files.
|
|---|
| 1497 | #
|
|---|
| 1498 | # @todo
|
|---|
| 1499 | # 1. Download corruption / continuation.
|
|---|
| 1500 | # 2. It's quite possible that there is one too many indirect dependency now...
|
|---|
| 1501 | #
|
|---|
| 1502 |
|
|---|
| 1503 | ## generates the fetch rule
|
|---|
| 1504 | define def_fetch_src_fetch_rule
|
|---|
| 1505 | # Indirect goal for downloading something.
|
|---|
| 1506 | .PRECIOUS: $(out)
|
|---|
| 1507 | $(out) + $($(target)_$(srcname)_FETCH_OUTPUT_) +| $($(target)_$(srcname)_FETCH_OUTPUT_MAYBE_) : \
|
|---|
| 1508 | | $($(target)_$(srcname)_FETCH_DEPORD_)
|
|---|
| 1509 | $$(call MSG_FETCH_DL,$(target),$(source),$(out))
|
|---|
| 1510 | @## @todo do fancy stuff like download continuation.
|
|---|
| 1511 | $$(QUIET)$$(RM) -f $(out)
|
|---|
| 1512 | $($(target)_$(srcname)_FETCH_CMDS_)
|
|---|
| 1513 | $$(QUIET)$(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out))
|
|---|
| 1514 |
|
|---|
| 1515 |
|
|---|
| 1516 |
|
|---|
| 1517 | # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
|
|---|
| 1518 | $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
|
|---|
| 1519 | $$(call MSG_FETCH_CHK,$(target),$(source),$(out))
|
|---|
| 1520 | $$(QUIET)$$(RM) -f $$@
|
|---|
| 1521 | @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
|
|---|
| 1522 | @## @todo do fancy stuff like download continuation.
|
|---|
| 1523 | $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out), true) ) \
|
|---|
| 1524 | || ( $$(RM_EXT) -f $(out) \
|
|---|
| 1525 | && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory )
|
|---|
| 1526 | $$(QUIET2)$$(APPEND) $$@
|
|---|
| 1527 |
|
|---|
| 1528 | _TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
|
|---|
| 1529 |
|
|---|
| 1530 | # Just a little precaution.
|
|---|
| 1531 | .NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
|
|---|
| 1532 |
|
|---|
| 1533 | endef
|
|---|
| 1534 |
|
|---|
| 1535 | ## generates the unpack rule
|
|---|
| 1536 | define def_fetch_src_unpack_rule
|
|---|
| 1537 | # This is the unpack rule. it has an order-only dependency on the download check.
|
|---|
| 1538 | $(out) + $($(target)_$(srcname)_UNPACK_OUTPUT_) +| $($(target)_$(srcname)_UNPACK_OUTPUT_MAYBE_) : \
|
|---|
| 1539 | $($(target)_$(srcname)_UNPACK_DEPEND_) \
|
|---|
| 1540 | | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size)
|
|---|
| 1541 | $$(call MSG_FETCH_UP,$(target),$(archive),$(inst))
|
|---|
| 1542 | $$(QUIET)$$(RM) -f $(out)
|
|---|
| 1543 | @# if the source archive doesn't exist fetch it (can have been deleted to save space).
|
|---|
| 1544 | $$(QUIET)test -f $(archive) \
|
|---|
| 1545 | || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
|
|---|
| 1546 | && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory )
|
|---|
| 1547 | $($(target)_$(srcname)_UNPACK_CMDS_)
|
|---|
| 1548 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
|
|---|
| 1549 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(out))
|
|---|
| 1550 |
|
|---|
| 1551 | $(eval _TARGET_$(target)_UNPACKED += $(out))
|
|---|
| 1552 | _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
|
|---|
| 1553 |
|
|---|
| 1554 | .NOTPARALLEL: $(out)
|
|---|
| 1555 |
|
|---|
| 1556 | endef
|
|---|
| 1557 |
|
|---|
| 1558 | ## Processes a fetch source
|
|---|
| 1559 | #
|
|---|
| 1560 | define def_fetch_src
|
|---|
| 1561 | #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
|
|---|
| 1562 |
|
|---|
| 1563 | # common
|
|---|
| 1564 | srcname := $(notdir $(source))
|
|---|
| 1565 | inst := $(firstword \
|
|---|
| 1566 | $($(target)_$(source)_INST)\
|
|---|
| 1567 | $($(target)_$(srcname)_INST)\
|
|---|
| 1568 | $($(source)_INST)\
|
|---|
| 1569 | $($(srcname)_INST)\
|
|---|
| 1570 | $($(target)_INST)\
|
|---|
| 1571 | )
|
|---|
| 1572 | ifneq ($(patsubst %/,ok,$(inst)),ok)
|
|---|
| 1573 | $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
|
|---|
| 1574 | endif
|
|---|
| 1575 | INSTARGET_$(target)_$(srcname) := $(inst)
|
|---|
| 1576 | fetchdir := $(firstword \
|
|---|
| 1577 | $($(target)_$(source)_FETCHDIR)\
|
|---|
| 1578 | $($(target)_$(srcname)_FETCHDIR)\
|
|---|
| 1579 | $($(source)_FETCHDIR)\
|
|---|
| 1580 | $($(srcname)_FETCHDIR)\
|
|---|
| 1581 | $($(target)_FETCHDIR)\
|
|---|
| 1582 | $(FETCHDIR)\
|
|---|
| 1583 | $(PATH_TARGET)\
|
|---|
| 1584 | )
|
|---|
| 1585 | deps := \
|
|---|
| 1586 | $($(target)_$(source)_DEPS)\
|
|---|
| 1587 | $($(target)_$(srcname)_DEPS)\
|
|---|
| 1588 | $($(source)_DEPS)\
|
|---|
| 1589 | $($(srcname)_DEPS)\
|
|---|
| 1590 | $($(target)_DEPS)
|
|---|
| 1591 | orderdeps := \
|
|---|
| 1592 | $($(target)_$(source)_ORDERDEPS)\
|
|---|
| 1593 | $($(target)_$(srcname)_ORDERDEPS)\
|
|---|
| 1594 | $($(source)_ORDERDEPS)\
|
|---|
| 1595 | $($(srcname)_ORDERDEPS)\
|
|---|
| 1596 | $($(target)_ORDERDEPS)
|
|---|
| 1597 | md5 := $(firstword \
|
|---|
| 1598 | $($(target)_$(source)_MD5)\
|
|---|
| 1599 | $($(target)_$(srcname)_MD5)\
|
|---|
| 1600 | $($(source)_MD5)\
|
|---|
| 1601 | $($(srcname)_MD5)\
|
|---|
| 1602 | $($(target)_MD5)\
|
|---|
| 1603 | )
|
|---|
| 1604 | size := $(firstword \
|
|---|
| 1605 | $($(target)_$(source)_SIZE)\
|
|---|
| 1606 | $($(target)_$(srcname)_SIZE)\
|
|---|
| 1607 | $($(source)_SIZE)\
|
|---|
| 1608 | $($(srcname)_SIZE)\
|
|---|
| 1609 | $($(target)_SIZE)\
|
|---|
| 1610 | )
|
|---|
| 1611 | dep := # not legal for fetch and unpack tools
|
|---|
| 1612 |
|
|---|
| 1613 |
|
|---|
| 1614 | #
|
|---|
| 1615 | # The fetching.
|
|---|
| 1616 | #
|
|---|
| 1617 | out := $(fetchdir)/$(srcname)
|
|---|
| 1618 | archive := $(out)
|
|---|
| 1619 | TARGET_$(target)_$(srcname) := $(out)
|
|---|
| 1620 | dirdep := $(call DIRDEP,$(fetchdir))
|
|---|
| 1621 | tool := $(firstword \
|
|---|
| 1622 | $($(target)_$(source)_FETCHTOOL)\
|
|---|
| 1623 | $($(target)_$(srcname)_FETCHTOOL)\
|
|---|
| 1624 | $($(target)_$(source)_TOOL)\
|
|---|
| 1625 | $($(target)_$(srcname)_TOOL)\
|
|---|
| 1626 | $($(source)_FETCHTOOL)\
|
|---|
| 1627 | $($(srcname)_FETCHTOOL)\
|
|---|
| 1628 | $($(source)_TOOL)\
|
|---|
| 1629 | $($(srcname)_TOOL)\
|
|---|
| 1630 | $($(target)_FETCHTOOL)\
|
|---|
| 1631 | $($(target)_TOOL)\
|
|---|
| 1632 | )
|
|---|
| 1633 | flags :=\
|
|---|
| 1634 | $(TOOL_$(tool)_FETCHFLAGS)\
|
|---|
| 1635 | $(FETCHFLAGS)\
|
|---|
| 1636 | $($(target)_FETCHFLAGS)\
|
|---|
| 1637 | $($(srcname)_FETCHFLAGS)\
|
|---|
| 1638 | $($(source)_FETCHFLAGS)\
|
|---|
| 1639 | $($(target)_$(srcname)_FETCHFLAGS)\
|
|---|
| 1640 | $($(target)_$(source)_FETCHFLAGS)
|
|---|
| 1641 |
|
|---|
| 1642 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
|
|---|
| 1643 |
|
|---|
| 1644 | ifndef TOOL_$(tool)_FETCH_CMDS
|
|---|
| 1645 | $(warning kBuild: tools: \
|
|---|
| 1646 | 1 $($(target)_$(source)_FETCHTOOL)\
|
|---|
| 1647 | 2 $($(target)_$(srcname)_FETCHTOOL)\
|
|---|
| 1648 | 3 $($(target)_$(source)_TOOL)\
|
|---|
| 1649 | 4 $($(target)_$(srcname)_TOOL)\
|
|---|
| 1650 | 5 $($(source)_FETCHTOOL)\
|
|---|
| 1651 | 6 $($(srcname)_FETCHTOOL)\
|
|---|
| 1652 | 7 $($(source)_TOOL)\
|
|---|
| 1653 | 8 $($(srcname)_TOOL)\
|
|---|
| 1654 | 9 $($(target)_FETCHTOOL)\
|
|---|
| 1655 | 10 $($(target)_TOOL) )
|
|---|
| 1656 | $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
|
|---|
| 1657 | endif
|
|---|
| 1658 |
|
|---|
| 1659 | # call the tool
|
|---|
| 1660 | $(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS)
|
|---|
| 1661 | $(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT)
|
|---|
| 1662 | $(target)_$(srcname)_FETCH_OUTPUT_MAYBE_ := $(TOOL_$(tool)_FETCH_OUTPUT_MAYBE)
|
|---|
| 1663 | $(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
|
|---|
| 1664 | $(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps)
|
|---|
| 1665 |
|
|---|
| 1666 | # generate the fetch rule.
|
|---|
| 1667 | $(eval $(def_fetch_src_fetch_rule))
|
|---|
| 1668 |
|
|---|
| 1669 |
|
|---|
| 1670 | #
|
|---|
| 1671 | # The unpacking / installing.
|
|---|
| 1672 | #
|
|---|
| 1673 | out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
|
|---|
| 1674 | dirdep := $(call DIRDEP,$(inst))
|
|---|
| 1675 | tool := $(firstword \
|
|---|
| 1676 | $($(target)_$(source)_UNPACKTOOL)\
|
|---|
| 1677 | $($(target)_$(srcname)_UNPACKTOOL)\
|
|---|
| 1678 | $($(target)_$(source)_TOOL)\
|
|---|
| 1679 | $($(target)_$(srcname)_TOOL)\
|
|---|
| 1680 | $($(source)_UNPACKTOOL)\
|
|---|
| 1681 | $($(srcname)_UNPACKTOOL)\
|
|---|
| 1682 | $($(source)_TOOL)\
|
|---|
| 1683 | $($(srcname)_TOOL)\
|
|---|
| 1684 | $($(target)_UNPACKTOOL)\
|
|---|
| 1685 | $($(target)_TOOL) \
|
|---|
| 1686 | )
|
|---|
| 1687 | ifeq ($(tool),)
|
|---|
| 1688 | tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
|
|---|
| 1689 | $(eval $(value def_tools_include))
|
|---|
| 1690 | endif
|
|---|
| 1691 | flags :=\
|
|---|
| 1692 | $(TOOL_$(tool)_UNPACKFLAGS)\
|
|---|
| 1693 | $(UNPACKFLAGS)\
|
|---|
| 1694 | $($(target)_UNPACKFLAGS)\
|
|---|
| 1695 | $($(srcname)_UNPACKFLAGS)\
|
|---|
| 1696 | $($(source)_UNPACKFLAGS)\
|
|---|
| 1697 | $($(target)_$(srcname)_UNPACKFLAGS)\
|
|---|
| 1698 | $($(target)_$(source)_UNPACKFLAGS)
|
|---|
| 1699 |
|
|---|
| 1700 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
|
|---|
| 1701 | ifndef TOOL_$(tool)_UNPACK_CMDS
|
|---|
| 1702 | $(warning kBuild: tools: \
|
|---|
| 1703 | 1 $($(target)_$(source)_UNPACKTOOL)\
|
|---|
| 1704 | 2 $($(target)_$(srcname)_UNPACKTOOL)\
|
|---|
| 1705 | 3 $($(target)_$(source)_TOOL)\
|
|---|
| 1706 | 4 $($(target)_$(srcname)_TOOL)\
|
|---|
| 1707 | 5 $($(source)_UNPACKTOOL)\
|
|---|
| 1708 | 6 $($(srcname)_UNPACKTOOL)\
|
|---|
| 1709 | 7 $($(source)_TOOL)\
|
|---|
| 1710 | 8 $($(srcname)_TOOL)\
|
|---|
| 1711 | 9 $($(target)_UNPACKTOOL)\
|
|---|
| 1712 | 10 $($(target)_TOOL) \
|
|---|
| 1713 | 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
|
|---|
| 1714 | )
|
|---|
| 1715 | $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
|
|---|
| 1716 | endif
|
|---|
| 1717 |
|
|---|
| 1718 | # call the tool
|
|---|
| 1719 | $(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS)
|
|---|
| 1720 | $(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT)
|
|---|
| 1721 | $(target)_$(srcname)_UNPACK_OUTPUT_MAYBE_ := $(TOOL_$(tool)_UNPACK_OUTPUT_MAYBE)
|
|---|
| 1722 | $(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
|
|---|
| 1723 | $(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps)
|
|---|
| 1724 |
|
|---|
| 1725 | # generate the fetch rule.
|
|---|
| 1726 | $(eval $(def_fetch_src_unpack_rule))
|
|---|
| 1727 |
|
|---|
| 1728 | _DIRS += $(inst) $(fetchdir)
|
|---|
| 1729 |
|
|---|
| 1730 | endef
|
|---|
| 1731 |
|
|---|
| 1732 |
|
|---|
| 1733 | ##
|
|---|
| 1734 | # Define the target level rules for a fetch.
|
|---|
| 1735 | # @param target
|
|---|
| 1736 | # @param out
|
|---|
| 1737 | # @param inst
|
|---|
| 1738 | # @param _TARGET_$(target)_UNPACKED
|
|---|
| 1739 | # @param _TARGET_$(target)_DIGEST
|
|---|
| 1740 | # @param bld_trg
|
|---|
| 1741 | # @param bld_trg_arch
|
|---|
| 1742 | define def_fetch_rules
|
|---|
| 1743 |
|
|---|
| 1744 | $(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
|
|---|
| 1745 | $$(call MSG_FETCH_OK,$(target))
|
|---|
| 1746 | $$(QUIET)$$(RM) -f $$@ $$@.tmp
|
|---|
| 1747 | $$(QUIET2)$$(APPEND) $$@.tmp '$(notdir $(out))'
|
|---|
| 1748 | $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
|
|---|
| 1749 | $$(QUIET)$$(MV) -f $$@.tmp $$@
|
|---|
| 1750 |
|
|---|
| 1751 | $(out)_unfetched:
|
|---|
| 1752 | $$(call MSG_UNFETCH,$(target))
|
|---|
| 1753 | $$(QUIET)$$(RM) -f $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
|
|---|
| 1754 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@) \
|
|---|
| 1755 | $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
|
|---|
| 1756 | $$(QUIET)$$(RM) -f $(out).lst $(out)
|
|---|
| 1757 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@)
|
|---|
| 1758 |
|
|---|
| 1759 | $(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
|
|---|
| 1760 | $$(QUIET)$$(RM) -f $$@
|
|---|
| 1761 | $$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(wildcard $(out).lst)\
|
|---|
| 1762 | ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target)))
|
|---|
| 1763 | $$(QUIET)$$(if $$(wildcard $(out).lst ),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched)
|
|---|
| 1764 | $$(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 $$@))
|
|---|
| 1765 | $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
|
|---|
| 1766 |
|
|---|
| 1767 | .NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
|
|---|
| 1768 |
|
|---|
| 1769 | endef
|
|---|
| 1770 |
|
|---|
| 1771 |
|
|---|
| 1772 | ##
|
|---|
| 1773 | # Deal with one fetch target.
|
|---|
| 1774 | # @param target
|
|---|
| 1775 | # @param bld_trg
|
|---|
| 1776 | # @param bld_trg_arch
|
|---|
| 1777 | define def_fetch
|
|---|
| 1778 | # common
|
|---|
| 1779 | INSTARGET_$(target) := $($(target)_INST)
|
|---|
| 1780 | ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
|
|---|
| 1781 | $(error kBuild: Bad or missing INST property for target '$(target)'. \
|
|---|
| 1782 | $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
|
|---|
| 1783 | endif
|
|---|
| 1784 | _TARGET_$(target)_FETCHED :=
|
|---|
| 1785 | _TARGET_$(target)_UNPACKED :=
|
|---|
| 1786 | _TARGET_$(target)_DIGEST :=
|
|---|
| 1787 |
|
|---|
| 1788 | # The 'sources'.
|
|---|
| 1789 | #$ (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)))
|
|---|
| 1790 | $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
|---|
| 1791 | $(eval $(value def_fetch_src)))
|
|---|
| 1792 |
|
|---|
| 1793 | # The target.
|
|---|
| 1794 | inst := $(INSTARGET_$(target))
|
|---|
| 1795 | out := $(inst)_kBuild_fetch_$(target)
|
|---|
| 1796 |
|
|---|
| 1797 | $(eval includedep $(out))
|
|---|
| 1798 |
|
|---|
| 1799 | $(eval $(def_fetch_rules))
|
|---|
| 1800 |
|
|---|
| 1801 | # Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
|
|---|
| 1802 | $(target): $(out)
|
|---|
| 1803 | $(target)_unfetch: $(out)_unfetched
|
|---|
| 1804 |
|
|---|
| 1805 | _FETCHES += $(out)
|
|---|
| 1806 | _DOWNLOADS += $(_TARGET_$(target)_FETCHED)
|
|---|
| 1807 | _UNPACKS += $(_TARGET_$(target)_UNPACKED)
|
|---|
| 1808 | _UNFETCHES += $(out)_unfetched
|
|---|
| 1809 | _DIRS += $(inst)
|
|---|
| 1810 |
|
|---|
| 1811 | endef
|
|---|
| 1812 |
|
|---|
| 1813 | # Walk the FETCH target lists.
|
|---|
| 1814 | bld_trg := $(BUILD_TARGET)
|
|---|
| 1815 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
|---|
| 1816 | $(foreach target, $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1817 | $(eval $(value def_fetch)))
|
|---|
| 1818 |
|
|---|
| 1819 | # some aliases.
|
|---|
| 1820 | download: $(_DOWNLOADS)
|
|---|
| 1821 | unpack: $(_UNPACKS)
|
|---|
| 1822 | fetch: $(_FETCHES)
|
|---|
| 1823 | unfetch: $(_UNFETCHES)
|
|---|
| 1824 |
|
|---|
| 1825 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 1826 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 1827 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done fetching targets)
|
|---|
| 1828 | $(info stat: $(make-stats ))
|
|---|
| 1829 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 1830 | endif
|
|---|
| 1831 |
|
|---|
| 1832 |
|
|---|
| 1833 |
|
|---|
| 1834 | ##
|
|---|
| 1835 | ## Patching.
|
|---|
| 1836 | ##
|
|---|
| 1837 | ##
|
|---|
| 1838 | #define def_patch_src
|
|---|
| 1839 | #
|
|---|
| 1840 | #endef
|
|---|
| 1841 | #
|
|---|
| 1842 | #
|
|---|
| 1843 | ## Deal with one patch target.
|
|---|
| 1844 | #define def_patch
|
|---|
| 1845 | #
|
|---|
| 1846 | #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
|---|
| 1847 | # $(eval $(value def_patch_src)))
|
|---|
| 1848 | #
|
|---|
| 1849 | #_PATCHES +=
|
|---|
| 1850 | #endef
|
|---|
| 1851 | #
|
|---|
| 1852 | #$(foreach target, $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 1853 | # $(eval $(value def_patch)))
|
|---|
| 1854 | #
|
|---|
| 1855 |
|
|---|
| 1856 |
|
|---|
| 1857 | #
|
|---|
| 1858 | # Object processing.
|
|---|
| 1859 | #
|
|---|
| 1860 |
|
|---|
| 1861 | ## wrapper the compile command dependency check.
|
|---|
| 1862 | ifndef NO_COMPILE_CMDS_DEPS
|
|---|
| 1863 | _DEP_COMPILE_CMDS = $(comp-cmds $(target)_$(source)_CMDS_PREV_,$(target)_$(source)_CMDS_,FORCE)
|
|---|
| 1864 | else
|
|---|
| 1865 | _DEP_COMPILE_CMDS =
|
|---|
| 1866 | endif
|
|---|
| 1867 |
|
|---|
| 1868 | ## Generates the rules for building a specific object, and the aliases
|
|---|
| 1869 | # for building a source file.
|
|---|
| 1870 | # @param $(obj) The object file.
|
|---|
| 1871 | define def_target_source_rule
|
|---|
| 1872 |
|
|---|
| 1873 | ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE
|
|---|
| 1874 | $(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
|
|---|
| 1875 | $($(target)_$(source)_DEPEND_) \
|
|---|
| 1876 | $(_DEP_COMPILE_CMDS) \
|
|---|
| 1877 | | \
|
|---|
| 1878 | $($(target)_$(source)_DEPORD_) \
|
|---|
| 1879 | $$($(target)_INTERMEDIATES)
|
|---|
| 1880 | $$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
|---|
| 1881 | else
|
|---|
| 1882 | $(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
|
|---|
| 1883 | $($(target)_$(source)_DEPEND_) \
|
|---|
| 1884 | $(_DEP_COMPILE_CMDS) \
|
|---|
| 1885 | | \
|
|---|
| 1886 | $($(target)_$(source)_DEPORD_) \
|
|---|
| 1887 | $$($(target)_INTERMEDIATES)
|
|---|
| 1888 | $$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
|---|
| 1889 | ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
|
|---|
| 1890 | $$(QUIET)$$(RM) -f $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
|
|---|
| 1891 | endif
|
|---|
| 1892 | endif
|
|---|
| 1893 |
|
|---|
| 1894 | $($(target)_$(source)_CMDS_)
|
|---|
| 1895 |
|
|---|
| 1896 | ifndef NO_COMPILE_CMDS_DEPS
|
|---|
| 1897 | $$(QUIET2)$$(APPEND) '$(dep)'
|
|---|
| 1898 | $$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(source)_CMDS_PREV_'
|
|---|
| 1899 | $$(QUIET2)$$(APPEND) -v '$(dep)' '$(target)_$(source)_CMDS_'
|
|---|
| 1900 | $$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
|---|
| 1901 | endif
|
|---|
| 1902 |
|
|---|
| 1903 | $(basename $(notdir $(obj))).o: $(obj)
|
|---|
| 1904 | $(basename $(notdir $(obj))).obj: $(obj)
|
|---|
| 1905 | endef
|
|---|
| 1906 |
|
|---|
| 1907 |
|
|---|
| 1908 | ## wrapper the link command dependency check.
|
|---|
| 1909 | ifndef NO_COMPILE_CMDS_DEPS
|
|---|
| 1910 | _DEP_LINK_CMDS = $(comp-cmds $(target)_CMDS_PREV_,$(target)_CMDS_,FORCE)
|
|---|
| 1911 | else
|
|---|
| 1912 | _DEP_LINK_CMDS =
|
|---|
| 1913 | endif
|
|---|
| 1914 |
|
|---|
| 1915 | ## Generate the link rule for a target.
|
|---|
| 1916 | # @param $(target) The normalized target name.
|
|---|
| 1917 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
|---|
| 1918 | # @param $(dep) The name of the dependency file.
|
|---|
| 1919 | # @param $(out)
|
|---|
| 1920 | # @param $($(target)_OUTPUT_) Output files from the link.
|
|---|
| 1921 | # @param $($(target)_OUTPUT_MAYBE_) Output files that the link may perhaps create.
|
|---|
| 1922 | # @param $($(target)_DEPEND_) Dependencies.
|
|---|
| 1923 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
|---|
| 1924 | # @param $($(target)_CMDS_) The link commands.
|
|---|
| 1925 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
|---|
| 1926 | define def_link_rule
|
|---|
| 1927 | $(out) + $($(target)_OUTPUT_) +| $($(target)_OUTPUT_MAYBE_) : \
|
|---|
| 1928 | $($(target)_DEPEND_) \
|
|---|
| 1929 | $(_DEP_LINK_CMDS) \
|
|---|
| 1930 | | \
|
|---|
| 1931 | $($(target)_DEPORD_)
|
|---|
| 1932 | $$(call MSG_LINK,$(target),$$@,$(tool_do))
|
|---|
| 1933 | $$(QUIET)$$(RM) -f $(dep) $(out) $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
|
|---|
| 1934 |
|
|---|
| 1935 | $($(target)_CMDS_)
|
|---|
| 1936 |
|
|---|
| 1937 | ifndef NO_LINK_CMDS_DEPS
|
|---|
| 1938 | $$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_'
|
|---|
| 1939 | $$(QUIET2)$$(APPEND) -v '$(dep)' '$(target)_CMDS_'
|
|---|
| 1940 | $$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
|---|
| 1941 | endif
|
|---|
| 1942 |
|
|---|
| 1943 | $(basename $(notdir $(out))): $(out)
|
|---|
| 1944 |
|
|---|
| 1945 | endef
|
|---|
| 1946 |
|
|---|
| 1947 |
|
|---|
| 1948 | ## Generate the link & lib install rule
|
|---|
| 1949 | # @param $(target) Normalized target name.
|
|---|
| 1950 | # @param $(out) The build target.
|
|---|
| 1951 | # @param $(INSTARGET_$(target)) The installation targets.
|
|---|
| 1952 | # @param $(mode) The file mode (optional)
|
|---|
| 1953 | define def_link_install_rule
|
|---|
| 1954 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
|---|
| 1955 | $$(call MSG_INST_TRG,$(target),$(out),$$@)
|
|---|
| 1956 | $$(QUIET)$$(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
|---|
| 1957 |
|
|---|
| 1958 | ifdef KBUILD_DO_AUTO_INSTALL
|
|---|
| 1959 | $(basename $(notdir $(out))): $(INSTARGET_$(target))
|
|---|
| 1960 | endif
|
|---|
| 1961 | endef
|
|---|
| 1962 |
|
|---|
| 1963 |
|
|---|
| 1964 | ## def_src_handler_*
|
|---|
| 1965 | #
|
|---|
| 1966 | # @{
|
|---|
| 1967 | define def_src_handler_c
|
|---|
| 1968 | type := C
|
|---|
| 1969 | $(kb-src-one )
|
|---|
| 1970 | endef
|
|---|
| 1971 |
|
|---|
| 1972 | define def_src_handler_cxx
|
|---|
| 1973 | type := CXX
|
|---|
| 1974 | $(kb-src-one )
|
|---|
| 1975 | endef
|
|---|
| 1976 |
|
|---|
| 1977 | define def_src_handler_objc
|
|---|
| 1978 | type := OBJC
|
|---|
| 1979 | $(kb-src-one )
|
|---|
| 1980 | endef
|
|---|
| 1981 |
|
|---|
| 1982 | define def_src_handler_asm
|
|---|
| 1983 | type := AS
|
|---|
| 1984 | $(kb-src-one )
|
|---|
| 1985 | endef
|
|---|
| 1986 |
|
|---|
| 1987 | define def_src_handler_rc
|
|---|
| 1988 | type := RC
|
|---|
| 1989 | $(kb-src-one )
|
|---|
| 1990 | endef
|
|---|
| 1991 |
|
|---|
| 1992 | define def_src_handler_obj
|
|---|
| 1993 | ifeq ($(defpath),)
|
|---|
| 1994 | $(target)_OBJS_ += $(source)
|
|---|
| 1995 | else
|
|---|
| 1996 | $(target)_OBJS_ += $(abspathex $(source), $(defpath))
|
|---|
| 1997 | endif
|
|---|
| 1998 | endef
|
|---|
| 1999 | ## @}
|
|---|
| 2000 |
|
|---|
| 2001 | ## Handle one source.
|
|---|
| 2002 | # .
|
|---|
| 2003 | define def_src_handler_one
|
|---|
| 2004 | suff := $(suffix $(source))
|
|---|
| 2005 | src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) ))
|
|---|
| 2006 | handler := $(patsubst $(suff):%,%,$(src_handler))
|
|---|
| 2007 | #$ (warning def_src_handler_one: source=$(source) suff=$(suff) src_handler=$(src_handler) handler=$(handler))
|
|---|
| 2008 | ifneq ($(handler),)
|
|---|
| 2009 | $(eval $(value $(handler)))
|
|---|
| 2010 | else
|
|---|
| 2011 | othersrc += $(source)
|
|---|
| 2012 | endif
|
|---|
| 2013 | endef
|
|---|
| 2014 |
|
|---|
| 2015 | ## Generic macro for processing all target sources.
|
|---|
| 2016 | # @param $(target) Normalized target name.
|
|---|
| 2017 | # @param $(defpath)
|
|---|
| 2018 | # @param much-more...
|
|---|
| 2019 | # @returns othersrc, $(target)_OBJS_, ++
|
|---|
| 2020 | define def_target_sources
|
|---|
| 2021 | target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS)
|
|---|
| 2022 | $(foreach source,\
|
|---|
| 2023 | $($(target)_SOURCES)\
|
|---|
| 2024 | $($(target)_SOURCES.$(bld_trg))\
|
|---|
| 2025 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2026 | $($(target)_SOURCES.$(bld_trg_arch))\
|
|---|
| 2027 | $($(target)_SOURCES.$(bld_trg_cpu))\
|
|---|
| 2028 | $($(target)_SOURCES.$(bld_type))\
|
|---|
| 2029 | ,$(eval $(value def_src_handler_one)) )
|
|---|
| 2030 | endef
|
|---|
| 2031 |
|
|---|
| 2032 |
|
|---|
| 2033 |
|
|---|
| 2034 | ## Generic macro for generating the install rule(s) for a target
|
|---|
| 2035 | # and update the globals with default out.
|
|---|
| 2036 | #
|
|---|
| 2037 | # @param $(target) Normalized target name.
|
|---|
| 2038 | # @param $(out) The output file.
|
|---|
| 2039 | # @param $(definst) The default _INST value.
|
|---|
| 2040 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
|---|
| 2041 | # @remark Only library uses this now.
|
|---|
| 2042 | define def_target_install_pluss
|
|---|
| 2043 | ifndef $(target)_NOINST
|
|---|
| 2044 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
|---|
| 2045 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
|---|
| 2046 |
|
|---|
| 2047 | $(eval $(def_link_install_rule))
|
|---|
| 2048 |
|
|---|
| 2049 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
|---|
| 2050 |
|
|---|
| 2051 | ifdef KBUILD_DO_AUTO_INSTALL
|
|---|
| 2052 | $(typevar) += $(INSTARGET_$(target))
|
|---|
| 2053 | else
|
|---|
| 2054 | $(typevar) += $(out)
|
|---|
| 2055 | endif
|
|---|
| 2056 | else # _NOINST
|
|---|
| 2057 | $(typevar) += $(out)
|
|---|
| 2058 | endif
|
|---|
| 2059 |
|
|---|
| 2060 | _OUT_FILES += $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_) $(out)
|
|---|
| 2061 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
|---|
| 2062 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
|---|
| 2063 | _OBJS += $($(target)_OBJS_)
|
|---|
| 2064 |
|
|---|
| 2065 | endef
|
|---|
| 2066 |
|
|---|
| 2067 |
|
|---|
| 2068 |
|
|---|
| 2069 | #
|
|---|
| 2070 | # LIBRARIES
|
|---|
| 2071 | #
|
|---|
| 2072 |
|
|---|
| 2073 | ## Library (one).
|
|---|
| 2074 | # @param $(target) Normalized library (target) name.
|
|---|
| 2075 | define def_lib
|
|---|
| 2076 | # library basics
|
|---|
| 2077 | ## @todo prefix
|
|---|
| 2078 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
|---|
| 2079 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
|---|
| 2080 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
|---|
| 2081 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
|---|
| 2082 | tool := $(call _TARGET_TOOL,$(target),AR)
|
|---|
| 2083 | ifeq ($(tool),)
|
|---|
| 2084 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
|---|
| 2085 | endif
|
|---|
| 2086 | name := $(firstword\
|
|---|
| 2087 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2088 | $($(target)_NAME.$(bld_trg_arch))\
|
|---|
| 2089 | $($(target)_NAME.$(bld_trg))\
|
|---|
| 2090 | $($(target)_NAME.$(bld_type))\
|
|---|
| 2091 | $($(target)_NAME)\
|
|---|
| 2092 | $(target))
|
|---|
| 2093 | outbase := $(call TARGET_BASE,$(name),$(target))
|
|---|
| 2094 | ifndef PATH_$(target)
|
|---|
| 2095 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
|---|
| 2096 | else
|
|---|
| 2097 | ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
|---|
| 2098 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
|---|
| 2099 | endif
|
|---|
| 2100 | endif
|
|---|
| 2101 | suff := $(firstword\
|
|---|
| 2102 | $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2103 | $($(target)_LIBSUFF.$(bld_trg))\
|
|---|
| 2104 | $($(target)_LIBSUFF)\
|
|---|
| 2105 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2106 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
|---|
| 2107 | $(TOOL_$(tool)_ARLIBSUFF)\
|
|---|
| 2108 | $(SUFF_LIB))
|
|---|
| 2109 | out := $(outbase)$(suff)
|
|---|
| 2110 | TARGET_$(target) := $(out)
|
|---|
| 2111 | $(target)_OBJS_ :=
|
|---|
| 2112 | defpath := $($(target)_PATH)
|
|---|
| 2113 | othersrc :=
|
|---|
| 2114 |
|
|---|
| 2115 | # source -> object
|
|---|
| 2116 | $(eval $(value def_target_sources))
|
|---|
| 2117 |
|
|---|
| 2118 | # library linking
|
|---|
| 2119 | tool := $(call _TARGET_TOOL,$(target),AR)
|
|---|
| 2120 | name := $(firstword\
|
|---|
| 2121 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2122 | $($(target)_NAME.$(bld_trg_arch))\
|
|---|
| 2123 | $($(target)_NAME.$(bld_trg))\
|
|---|
| 2124 | $($(target)_NAME.$(bld_type))\
|
|---|
| 2125 | $($(target)_NAME)\
|
|---|
| 2126 | $(target))
|
|---|
| 2127 | outbase := $(call TARGET_BASE,$(name),$(target))
|
|---|
| 2128 | flags :=\
|
|---|
| 2129 | $(TOOL_$(tool)_ARFLAGS)\
|
|---|
| 2130 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
|---|
| 2131 | $(ARFLAGS)\
|
|---|
| 2132 | $(ARFLAGS.$(bld_type))\
|
|---|
| 2133 | $($(target)_ARFLAGS)\
|
|---|
| 2134 | $($(target)_ARFLAGS.$(bld_type)) \
|
|---|
| 2135 | $($(target)_ARFLAGS.$(bld_trg)) \
|
|---|
| 2136 | $($(target)_ARFLAGS.$(bld_trg_arch)) \
|
|---|
| 2137 | $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2138 | $($(target)_ARFLAGS.$(bld_trg_cpu))
|
|---|
| 2139 | dirdep := $(call DIRDEP,$(dir $(out)))
|
|---|
| 2140 | deps := $($(target)_DEPS)
|
|---|
| 2141 | orderdeps := $($(target)_ORDERDEPS)
|
|---|
| 2142 |
|
|---|
| 2143 | # Adjust paths if we got a default path.
|
|---|
| 2144 | ifneq ($(defpath),)
|
|---|
| 2145 | $(target)_OBJS_ := $(abspathex $($(target)_OBJS_),$(defpath))
|
|---|
| 2146 | deps := $(abspathex $(deps),$(defpath))
|
|---|
| 2147 | orderdeps := $(abspathex $(orderdeps),$(defpath))
|
|---|
| 2148 | endif
|
|---|
| 2149 |
|
|---|
| 2150 |
|
|---|
| 2151 | # Custom pre-link actions.
|
|---|
| 2152 | ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
|---|
| 2153 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
|---|
| 2154 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
|---|
| 2155 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2156 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
|
|---|
| 2157 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
|
|---|
| 2158 | else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
|
|---|
| 2159 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
|
|---|
| 2160 | else ifdef $(target)_PRE_CMDS.$(bld_trg)
|
|---|
| 2161 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
|
|---|
| 2162 | else ifdef $(target)_PRE_CMDS.$(bld_type)
|
|---|
| 2163 | pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
|
|---|
| 2164 | else ifdef $(target)_PRE_CMDS
|
|---|
| 2165 | pre_cmds := $($(target)_PRE_CMDS)
|
|---|
| 2166 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
|---|
| 2167 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
|---|
| 2168 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
|---|
| 2169 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2170 | else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
|
|---|
| 2171 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
|
|---|
| 2172 | else ifdef PRE_CMDS.$(bld_trg_arch)
|
|---|
| 2173 | pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
|
|---|
| 2174 | else ifdef PRE_CMDS.$(bld_trg)
|
|---|
| 2175 | pre_cmds := $(PRE_CMDS.$(bld_trg))
|
|---|
| 2176 | else ifdef PRE_CMDS.$(bld_type)
|
|---|
| 2177 | pre_cmds := $(PRE_CMDS.$(bld_type))
|
|---|
| 2178 | else
|
|---|
| 2179 | pre_cmds := $(PRE_CMDS)
|
|---|
| 2180 | endif
|
|---|
| 2181 |
|
|---|
| 2182 | # Custom post-link actions.
|
|---|
| 2183 | ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
|---|
| 2184 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
|---|
| 2185 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
|---|
| 2186 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2187 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
|
|---|
| 2188 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
|
|---|
| 2189 | else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
|
|---|
| 2190 | post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
|
|---|
| 2191 | else ifdef $(target)_POST_CMDS.$(bld_trg)
|
|---|
| 2192 | post_cmds := $($(target)_POST_CMDS.$(bld_trg))
|
|---|
| 2193 | else ifdef $(target)_POST_CMDS.$(bld_type)
|
|---|
| 2194 | post_cmds := $($(target)_POST_CMDS.$(bld_type))
|
|---|
| 2195 | else ifdef $(target)_POST_CMDS
|
|---|
| 2196 | post_cmds := $($(target)_POST_CMDS)
|
|---|
| 2197 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
|---|
| 2198 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
|---|
| 2199 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
|---|
| 2200 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2201 | else ifdef POST_CMDS.$(bld_trg).$(bld_type)
|
|---|
| 2202 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
|
|---|
| 2203 | else ifdef POST_CMDS.$(bld_trg_arch)
|
|---|
| 2204 | post_cmds := $(POST_CMDS.$(bld_trg_arch))
|
|---|
| 2205 | else ifdef POST_CMDS.$(bld_trg)
|
|---|
| 2206 | post_cmds := $(POST_CMDS.$(bld_trg))
|
|---|
| 2207 | else ifdef POST_CMDS.$(bld_type)
|
|---|
| 2208 | post_cmds := $(POST_CMDS.$(bld_type))
|
|---|
| 2209 | else
|
|---|
| 2210 | post_cmds := $(POST_CMDS)
|
|---|
| 2211 | endif
|
|---|
| 2212 |
|
|---|
| 2213 | # eliminate this guy?
|
|---|
| 2214 | objs = $($(target)_OBJS_)
|
|---|
| 2215 |
|
|---|
| 2216 | # dependency file
|
|---|
| 2217 | dep := $(out)$(SUFF_DEP)
|
|---|
| 2218 | ifndef NO_LINK_CMDS_DEPS
|
|---|
| 2219 | _DEPFILES_INCLUDED += $(dep)
|
|---|
| 2220 | $(eval includedep $(dep))
|
|---|
| 2221 | endif
|
|---|
| 2222 |
|
|---|
| 2223 | # check that the tool is defined.
|
|---|
| 2224 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
|---|
| 2225 | $(warning kBuild: tools: \
|
|---|
| 2226 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2227 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
|---|
| 2228 | 3 $($(target)_$(source)TOOL) \
|
|---|
| 2229 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2230 | 5 $($(target)_TOOL.$(bld_trg)) \
|
|---|
| 2231 | 6 $($(target)_TOOL) \
|
|---|
| 2232 | 7 $($(source)TOOL) \
|
|---|
| 2233 | 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2234 | 9 $($(source)TOOL.$(bld_trg)) \
|
|---|
| 2235 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2236 | 11 $(TOOL.$(bld_trg)) \
|
|---|
| 2237 | 12 $(TOOL) )
|
|---|
| 2238 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
|---|
| 2239 | endif
|
|---|
| 2240 |
|
|---|
| 2241 | # call the tool
|
|---|
| 2242 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
|---|
| 2243 | ifneq ($(pre_cmds),)
|
|---|
| 2244 | $(target)_CMDS_ := $(TAB)$(pre_cmds)$(NL)$(TAB)$($(target)_CMDS_)
|
|---|
| 2245 | endif
|
|---|
| 2246 | ifneq ($(post_cmds),)
|
|---|
| 2247 | $(target)_CMDS_ := $($(target)_CMDS_)$(NL)$(TAB)$(post_cmds)
|
|---|
| 2248 | endif
|
|---|
| 2249 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
|---|
| 2250 | $(target)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
|
|---|
| 2251 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_OBJS_)
|
|---|
| 2252 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
|
|---|
| 2253 |
|
|---|
| 2254 | # generate the link rule.
|
|---|
| 2255 | $(eval $(def_link_rule))
|
|---|
| 2256 |
|
|---|
| 2257 | # installing and globals
|
|---|
| 2258 | $(eval $(value def_target_install_pluss))
|
|---|
| 2259 | endef
|
|---|
| 2260 |
|
|---|
| 2261 | # Process libraries
|
|---|
| 2262 | definst := $(PATH_LIB)
|
|---|
| 2263 | typevar := _LIBS
|
|---|
| 2264 | tool_do := LINK_LIBRARY
|
|---|
| 2265 | mode := 0644
|
|---|
| 2266 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
|---|
| 2267 |
|
|---|
| 2268 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 2269 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 2270 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done library targets)
|
|---|
| 2271 | $(info stat: $(make-stats ))
|
|---|
| 2272 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 2273 | endif
|
|---|
| 2274 |
|
|---|
| 2275 |
|
|---|
| 2276 | #
|
|---|
| 2277 | # Link operations.
|
|---|
| 2278 | #
|
|---|
| 2279 |
|
|---|
| 2280 | ##
|
|---|
| 2281 | # Link prolog
|
|---|
| 2282 | #
|
|---|
| 2283 | # @param $(target) Normalized target name.
|
|---|
| 2284 | # @param $(EXT) EXE,DLL,SYS.
|
|---|
| 2285 | # @param $(definst) The default _INST value.
|
|---|
| 2286 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
|---|
| 2287 | define def_link_common
|
|---|
| 2288 | # basics
|
|---|
| 2289 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
|---|
| 2290 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
|---|
| 2291 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
|---|
| 2292 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
|---|
| 2293 |
|
|---|
| 2294 | tool := $(call _TARGET_TOOL,$(target),LD)
|
|---|
| 2295 | name := $(firstword\
|
|---|
| 2296 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2297 | $($(target)_NAME.$(bld_trg_arch))\
|
|---|
| 2298 | $($(target)_NAME.$(bld_trg))\
|
|---|
| 2299 | $($(target)_NAME.$(bld_type))\
|
|---|
| 2300 | $($(target)_NAME)\
|
|---|
| 2301 | $(target))
|
|---|
| 2302 | outbase := $(call TARGET_BASE,$(name),$(target))
|
|---|
| 2303 | ifndef PATH_$(target)
|
|---|
| 2304 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
|---|
| 2305 | else
|
|---|
| 2306 | ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
|---|
| 2307 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
|---|
| 2308 | endif
|
|---|
| 2309 | endif
|
|---|
| 2310 | suff := $(firstword \
|
|---|
| 2311 | $($(target)_$(EXT)SUFF) \
|
|---|
| 2312 | $($(target)_$(EXT)SUFF) \
|
|---|
| 2313 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
|---|
| 2314 | $($(EXTPRE)SUFF_$(EXT)))
|
|---|
| 2315 | out := $(outbase)$(suff)
|
|---|
| 2316 | TARGET_$(target) := $(out)
|
|---|
| 2317 | $(target)_OBJS_ :=
|
|---|
| 2318 | defpath := $($(target)_PATH)
|
|---|
| 2319 | othersrc :=
|
|---|
| 2320 |
|
|---|
| 2321 | # source -> object
|
|---|
| 2322 | $(eval $(value def_target_sources))
|
|---|
| 2323 |
|
|---|
| 2324 | # more link stuff.
|
|---|
| 2325 | tool := $(call _TARGET_TOOL,$(target),LD)
|
|---|
| 2326 | name := $(firstword\
|
|---|
| 2327 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2328 | $($(target)_NAME.$(bld_trg_arch))\
|
|---|
| 2329 | $($(target)_NAME.$(bld_trg))\
|
|---|
| 2330 | $($(target)_NAME.$(bld_type))\
|
|---|
| 2331 | $($(target)_NAME)\
|
|---|
| 2332 | $(target))
|
|---|
| 2333 | outbase := $(call TARGET_BASE,$(name),$(target))
|
|---|
| 2334 | flags :=\
|
|---|
| 2335 | $(TOOL_$(tool)_LDFLAGS)\
|
|---|
| 2336 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
|---|
| 2337 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
|---|
| 2338 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
|---|
| 2339 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2340 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
|---|
| 2341 | $(foreach sdk, $(SDKS) \
|
|---|
| 2342 | $(SDKS.$(bld_type)) \
|
|---|
| 2343 | $(SDKS.$(bld_trg)) \
|
|---|
| 2344 | $(SDKS.$(bld_trg_arch)) \
|
|---|
| 2345 | $(SDKS.$(bld_trg).$(bld_trg_arch)),\
|
|---|
| 2346 | $(SDK_$(sdk)_LDFLAGS)\
|
|---|
| 2347 | $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
|
|---|
| 2348 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
|
|---|
| 2349 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
|
|---|
| 2350 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2351 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
|
|---|
| 2352 | $(LDFLAGS)\
|
|---|
| 2353 | $(LDFLAGS.$(bld_type))\
|
|---|
| 2354 | $(LDFLAGS.$(bld_trg))\
|
|---|
| 2355 | $(LDFLAGS.$(bld_trg_arch))\
|
|---|
| 2356 | $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2357 | $(LDFLAGS.$(bld_trg_cpu))\
|
|---|
| 2358 | $(foreach sdk, $($(target)_SDKS) \
|
|---|
| 2359 | $($(target)_SDKS.$(bld_type)) \
|
|---|
| 2360 | $($(target)_SDKS.$(bld_trg)) \
|
|---|
| 2361 | $($(target)_SDKS.$(bld_trg_arch)) \
|
|---|
| 2362 | $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\
|
|---|
| 2363 | $(SDK_$(sdk)_LDFLAGS)\
|
|---|
| 2364 | $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
|
|---|
| 2365 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
|
|---|
| 2366 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
|
|---|
| 2367 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2368 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
|
|---|
| 2369 | $($(target)_LDFLAGS)\
|
|---|
| 2370 | $($(target)_LDFLAGS.$(bld_type))\
|
|---|
| 2371 | $($(target)_LDFLAGS.$(bld_trg))\
|
|---|
| 2372 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
|---|
| 2373 | $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2374 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
|---|
| 2375 | libs :=\
|
|---|
| 2376 | $($(target)_LIBS.$(bld_trg_cpu))\
|
|---|
| 2377 | $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2378 | $($(target)_LIBS.$(bld_trg_arch))\
|
|---|
| 2379 | $($(target)_LIBS.$(bld_trg))\
|
|---|
| 2380 | $($(target)_LIBS.$(bld_type))\
|
|---|
| 2381 | $($(target)_LIBS)\
|
|---|
| 2382 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2383 | $($(target)_SDKS.$(bld_trg_arch)) \
|
|---|
| 2384 | $($(target)_SDKS.$(bld_trg)) \
|
|---|
| 2385 | $($(target)_SDKS.$(bld_type)) \
|
|---|
| 2386 | $($(target)_SDKS),\
|
|---|
| 2387 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
|---|
| 2388 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2389 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
|---|
| 2390 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
|---|
| 2391 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
|---|
| 2392 | $(SDK_$(sdk)_LIBS))\
|
|---|
| 2393 | $(LIBS.$(bld_trg_cpu))\
|
|---|
| 2394 | $(LIBS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2395 | $(LIBS.$(bld_trg_arch))\
|
|---|
| 2396 | $(LIBS.$(bld_trg))\
|
|---|
| 2397 | $(LIBS.$(bld_type))\
|
|---|
| 2398 | $(LIBS)\
|
|---|
| 2399 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2400 | $(SDKS.$(bld_trg_arch)) \
|
|---|
| 2401 | $(SDKS.$(bld_trg)) \
|
|---|
| 2402 | $(SDKS.$(bld_type)) \
|
|---|
| 2403 | $(SDKS),\
|
|---|
| 2404 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
|---|
| 2405 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2406 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
|---|
| 2407 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
|---|
| 2408 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
|---|
| 2409 | $(SDK_$(sdk)_LIBS))\
|
|---|
| 2410 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
|---|
| 2411 | $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2412 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
|---|
| 2413 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
|---|
| 2414 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
|---|
| 2415 | $(TOOL_$(tool)_LIBS)
|
|---|
| 2416 | libpath :=\
|
|---|
| 2417 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
|---|
| 2418 | $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2419 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
|---|
| 2420 | $($(target)_LIBPATH.$(bld_trg))\
|
|---|
| 2421 | $($(target)_LIBPATH.$(bld_type))\
|
|---|
| 2422 | $($(target)_LIBPATH)\
|
|---|
| 2423 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2424 | $($(target)_SDKS.$(bld_trg_arch)) \
|
|---|
| 2425 | $($(target)_SDKS.$(bld_trg)) \
|
|---|
| 2426 | $($(target)_SDKS.$(bld_type)) \
|
|---|
| 2427 | $($(target)_SDKS),\
|
|---|
| 2428 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
|---|
| 2429 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2430 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
|---|
| 2431 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
|---|
| 2432 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
|---|
| 2433 | $(SDK_$(sdk)_LIBPATH))\
|
|---|
| 2434 | $(LIBPATH.$(bld_trg_cpu))\
|
|---|
| 2435 | $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2436 | $(LIBPATH.$(bld_trg_arch))\
|
|---|
| 2437 | $(LIBPATH.$(bld_trg))\
|
|---|
| 2438 | $(LIBPATH.$(bld_type))\
|
|---|
| 2439 | $(LIBPATH)\
|
|---|
| 2440 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2441 | $(SDKS.$(bld_trg_arch)) \
|
|---|
| 2442 | $(SDKS.$(bld_trg)) \
|
|---|
| 2443 | $(SDKS.$(bld_type)) \
|
|---|
| 2444 | $(SDKS),\
|
|---|
| 2445 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
|---|
| 2446 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2447 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
|---|
| 2448 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
|---|
| 2449 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
|---|
| 2450 | $(SDK_$(sdk)_LIBPATH))\
|
|---|
| 2451 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
|---|
| 2452 | $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
|---|
| 2453 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
|---|
| 2454 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
|---|
| 2455 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
|---|
| 2456 | $(TOOL_$(tool)_LIBPATH)
|
|---|
| 2457 | dirdep := $(call DIRDEP,$(dir $(out)))
|
|---|
| 2458 | deps := $($(target)_DEPS)
|
|---|
| 2459 | orderdeps := $($(target)_ORDERDEPS)
|
|---|
| 2460 |
|
|---|
| 2461 | # Adjust paths if we got a default path.
|
|---|
| 2462 | ifneq ($(defpath),)
|
|---|
| 2463 | libpath := $(abspathex $(libpath),$(defpath))
|
|---|
| 2464 | $(target)_OBJS_ := $(abspathex $($(target)_OBJS_),$(defpath))
|
|---|
| 2465 | deps := $(abspathex $(deps),$(defpath))
|
|---|
| 2466 | orderdeps := $(abspathex $(orderdeps),$(defpath))
|
|---|
| 2467 | # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_PATH)/lib if relative to current dir!
|
|---|
| 2468 | endif
|
|---|
| 2469 |
|
|---|
| 2470 | # Custom pre-link actions.
|
|---|
| 2471 | ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
|---|
| 2472 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
|---|
| 2473 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
|---|
| 2474 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2475 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
|
|---|
| 2476 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
|
|---|
| 2477 | else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
|
|---|
| 2478 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
|
|---|
| 2479 | else ifdef $(target)_PRE_CMDS.$(bld_trg)
|
|---|
| 2480 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
|
|---|
| 2481 | else ifdef $(target)_PRE_CMDS.$(bld_type)
|
|---|
| 2482 | pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
|
|---|
| 2483 | else ifdef $(target)_PRE_CMDS
|
|---|
| 2484 | pre_cmds := $($(target)_PRE_CMDS)
|
|---|
| 2485 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
|---|
| 2486 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
|---|
| 2487 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
|---|
| 2488 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2489 | else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
|
|---|
| 2490 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
|
|---|
| 2491 | else ifdef PRE_CMDS.$(bld_trg_arch)
|
|---|
| 2492 | pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
|
|---|
| 2493 | else ifdef PRE_CMDS.$(bld_trg)
|
|---|
| 2494 | pre_cmds := $(PRE_CMDS.$(bld_trg))
|
|---|
| 2495 | else ifdef PRE_CMDS.$(bld_type)
|
|---|
| 2496 | pre_cmds := $(PRE_CMDS.$(bld_type))
|
|---|
| 2497 | else
|
|---|
| 2498 | pre_cmds := $(PRE_CMDS)
|
|---|
| 2499 | endif
|
|---|
| 2500 |
|
|---|
| 2501 | # Custom post-link actions.
|
|---|
| 2502 | ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
|---|
| 2503 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
|---|
| 2504 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
|---|
| 2505 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2506 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
|
|---|
| 2507 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
|
|---|
| 2508 | else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
|
|---|
| 2509 | post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
|
|---|
| 2510 | else ifdef $(target)_POST_CMDS.$(bld_trg)
|
|---|
| 2511 | post_cmds := $($(target)_POST_CMDS.$(bld_trg))
|
|---|
| 2512 | else ifdef $(target)_POST_CMDS.$(bld_type)
|
|---|
| 2513 | post_cmds := $($(target)_POST_CMDS.$(bld_type))
|
|---|
| 2514 | else ifdef $(target)_POST_CMDS
|
|---|
| 2515 | post_cmds := $($(target)_POST_CMDS)
|
|---|
| 2516 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
|---|
| 2517 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
|---|
| 2518 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
|---|
| 2519 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2520 | else ifdef POST_CMDS.$(bld_trg).$(bld_type)
|
|---|
| 2521 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
|
|---|
| 2522 | else ifdef POST_CMDS.$(bld_trg_arch)
|
|---|
| 2523 | post_cmds := $(POST_CMDS.$(bld_trg_arch))
|
|---|
| 2524 | else ifdef POST_CMDS.$(bld_trg)
|
|---|
| 2525 | post_cmds := $(POST_CMDS.$(bld_trg))
|
|---|
| 2526 | else ifdef POST_CMDS.$(bld_type)
|
|---|
| 2527 | post_cmds := $(POST_CMDS.$(bld_type))
|
|---|
| 2528 | else
|
|---|
| 2529 | post_cmds := $(POST_CMDS)
|
|---|
| 2530 | endif
|
|---|
| 2531 |
|
|---|
| 2532 | # eliminate this guy?
|
|---|
| 2533 | objs = $($(target)_OBJS_)
|
|---|
| 2534 |
|
|---|
| 2535 | # installation targets
|
|---|
| 2536 | ifndef $(target)_NOINST
|
|---|
| 2537 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
|---|
| 2538 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
|---|
| 2539 | ifdef KBUILD_DO_AUTO_INSTALL
|
|---|
| 2540 | $(typevar) += $(INSTARGET_$(target))
|
|---|
| 2541 | else
|
|---|
| 2542 | $(typevar) += $(out)
|
|---|
| 2543 | endif
|
|---|
| 2544 | # generate the install rule
|
|---|
| 2545 | $(eval $(def_link_install_rule))
|
|---|
| 2546 |
|
|---|
| 2547 | else # NOINST
|
|---|
| 2548 | INSTARGET_$(target) :=
|
|---|
| 2549 | $(typevar) += $(out)
|
|---|
| 2550 | endif # NOINST
|
|---|
| 2551 |
|
|---|
| 2552 | # dependency file
|
|---|
| 2553 | dep := $(outbase)$(SUFF_DEP)
|
|---|
| 2554 | ifndef NO_LINK_CMDS_DEPS
|
|---|
| 2555 | _DEPFILES_INCLUDED += $(dep)
|
|---|
| 2556 | $(eval includedep $(dep))
|
|---|
| 2557 | endif
|
|---|
| 2558 |
|
|---|
| 2559 | # check that the tool is defined.
|
|---|
| 2560 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
|---|
| 2561 | $(warning kBuild: tools: \
|
|---|
| 2562 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2563 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
|---|
| 2564 | 3 $($(target)_$(source)TOOL) \
|
|---|
| 2565 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2566 | 5 $($(target)_TOOL.$(bld_trg)) \
|
|---|
| 2567 | 6 $($(target)_TOOL) \
|
|---|
| 2568 | 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2569 | 8 $($(source)TOOL.$(bld_trg)) \
|
|---|
| 2570 | 9 $($(source)TOOL) \
|
|---|
| 2571 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2572 | 11 $(TOOL.$(bld_trg)) \
|
|---|
| 2573 | 12 $(TOOL) )
|
|---|
| 2574 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
|---|
| 2575 | endif
|
|---|
| 2576 |
|
|---|
| 2577 | # call the tool
|
|---|
| 2578 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
|---|
| 2579 | ifneq ($(pre_cmds),)
|
|---|
| 2580 | $(target)_CMDS_ := $(TAB)$(pre_cmds)$(NL)$(TAB)$($(target)_CMDS_)
|
|---|
| 2581 | endif
|
|---|
| 2582 | ifneq ($(post_cmds),)
|
|---|
| 2583 | $(target)_CMDS_ := $($(target)_CMDS_)$(NL)$(TAB)$(post_cmds)
|
|---|
| 2584 | endif
|
|---|
| 2585 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
|---|
| 2586 | $(target)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE)
|
|---|
| 2587 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_OBJS_)
|
|---|
| 2588 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
|
|---|
| 2589 |
|
|---|
| 2590 | # generate the link rule.
|
|---|
| 2591 | $(eval $(def_link_rule))
|
|---|
| 2592 |
|
|---|
| 2593 |
|
|---|
| 2594 | # Update globals.
|
|---|
| 2595 | _OBJS += $($(target)_OBJS_)
|
|---|
| 2596 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
|---|
| 2597 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
|---|
| 2598 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
|---|
| 2599 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
|---|
| 2600 |
|
|---|
| 2601 | endef
|
|---|
| 2602 |
|
|---|
| 2603 |
|
|---|
| 2604 | #
|
|---|
| 2605 | # BLDPROGS
|
|---|
| 2606 | #
|
|---|
| 2607 |
|
|---|
| 2608 | ## Build program (one).
|
|---|
| 2609 | # @param $(target) Normalized target (program) name.
|
|---|
| 2610 | define def_bldprog
|
|---|
| 2611 |
|
|---|
| 2612 | # set NOINST if not forced installation.
|
|---|
| 2613 | ifndef $(target)_INST
|
|---|
| 2614 | $(target)_NOINST := 1
|
|---|
| 2615 | endif
|
|---|
| 2616 |
|
|---|
| 2617 | # do the usual stuff.
|
|---|
| 2618 | $(eval $(value def_link_common))
|
|---|
| 2619 |
|
|---|
| 2620 | endef
|
|---|
| 2621 |
|
|---|
| 2622 | # Process build programs.
|
|---|
| 2623 | EXT := EXE
|
|---|
| 2624 | EXTPRE := HOST
|
|---|
| 2625 | tool_do := LINK_PROGRAM
|
|---|
| 2626 | definst := $(PATH_BIN)
|
|---|
| 2627 | typevar := _BLDPROGS
|
|---|
| 2628 | mode := 0755
|
|---|
| 2629 | bld_trg_base_var := PLATFORM
|
|---|
| 2630 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), $(eval $(value def_bldprog)))
|
|---|
| 2631 |
|
|---|
| 2632 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 2633 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 2634 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done build program targets)
|
|---|
| 2635 | $(info stat: $(make-stats ))
|
|---|
| 2636 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 2637 | endif
|
|---|
| 2638 |
|
|---|
| 2639 |
|
|---|
| 2640 | #
|
|---|
| 2641 | # DLLS
|
|---|
| 2642 | #
|
|---|
| 2643 |
|
|---|
| 2644 | # Process dlls
|
|---|
| 2645 | EXT := DLL
|
|---|
| 2646 | EXTPRE :=
|
|---|
| 2647 | tool_do := LINK_DLL
|
|---|
| 2648 | definst := $(PATH_DLL)
|
|---|
| 2649 | typevar := _DLLS
|
|---|
| 2650 | mode := 0644
|
|---|
| 2651 | bld_trg_base_var := TARGET
|
|---|
| 2652 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
|---|
| 2653 |
|
|---|
| 2654 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 2655 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 2656 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done dll targets)
|
|---|
| 2657 | $(info stat: $(make-stats ))
|
|---|
| 2658 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 2659 | endif
|
|---|
| 2660 |
|
|---|
| 2661 |
|
|---|
| 2662 | #
|
|---|
| 2663 | # IMPORT LIBRARIES
|
|---|
| 2664 | #
|
|---|
| 2665 | # - On OS/2 and windows these are libraries.
|
|---|
| 2666 | # - On other platforms they are fake DLLs.
|
|---|
| 2667 | #
|
|---|
| 2668 | EXTPRE :=
|
|---|
| 2669 | typevar := _IMPORT_LIBS
|
|---|
| 2670 | mode := 0644
|
|---|
| 2671 | bld_trg_base_var := TARGET
|
|---|
| 2672 | ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
|
|---|
| 2673 | EXT := LIB
|
|---|
| 2674 | tool_do := LINK_LIBRARY
|
|---|
| 2675 | definst := $(PATH_LIB)
|
|---|
| 2676 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
|---|
| 2677 | else
|
|---|
| 2678 | EXT := DLL
|
|---|
| 2679 | tool_do := LINK_DLL
|
|---|
| 2680 | definst := $(PATH_DLL)
|
|---|
| 2681 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
|---|
| 2682 | endif
|
|---|
| 2683 |
|
|---|
| 2684 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 2685 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 2686 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done import library targets)
|
|---|
| 2687 | $(info stat: $(make-stats ))
|
|---|
| 2688 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 2689 | endif
|
|---|
| 2690 |
|
|---|
| 2691 |
|
|---|
| 2692 | #
|
|---|
| 2693 | # PROGRAMS
|
|---|
| 2694 | #
|
|---|
| 2695 |
|
|---|
| 2696 | # Process programs
|
|---|
| 2697 | EXT := EXE
|
|---|
| 2698 | EXTPRE :=
|
|---|
| 2699 | tool_do := LINK_PROGRAM
|
|---|
| 2700 | definst := $(PATH_BIN)
|
|---|
| 2701 | typevar := _PROGRAMS
|
|---|
| 2702 | mode := 0755
|
|---|
| 2703 | bld_trg_base_var := TARGET
|
|---|
| 2704 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
|---|
| 2705 |
|
|---|
| 2706 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 2707 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 2708 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done program targets)
|
|---|
| 2709 | $(info stat: $(make-stats ))
|
|---|
| 2710 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 2711 | endif
|
|---|
| 2712 |
|
|---|
| 2713 |
|
|---|
| 2714 | #
|
|---|
| 2715 | # SYSMODS
|
|---|
| 2716 | #
|
|---|
| 2717 |
|
|---|
| 2718 | # Process sysmods
|
|---|
| 2719 | EXT := SYS
|
|---|
| 2720 | EXTPRE :=
|
|---|
| 2721 | tool_do := LINK_SYSMOD
|
|---|
| 2722 | definst := $(PATH_SYS)
|
|---|
| 2723 | typevar := _SYSMODS
|
|---|
| 2724 | mode := 0644
|
|---|
| 2725 | bld_trg_base_var := TARGET
|
|---|
| 2726 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
|---|
| 2727 |
|
|---|
| 2728 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 2729 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 2730 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done sysmod targets)
|
|---|
| 2731 | $(info stat: $(make-stats ))
|
|---|
| 2732 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 2733 | endif
|
|---|
| 2734 |
|
|---|
| 2735 |
|
|---|
| 2736 | #
|
|---|
| 2737 | # OTHERS
|
|---|
| 2738 | #
|
|---|
| 2739 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
|---|
| 2740 |
|
|---|
| 2741 |
|
|---|
| 2742 | #
|
|---|
| 2743 | # INSTALLS
|
|---|
| 2744 | #
|
|---|
| 2745 |
|
|---|
| 2746 | ## generate the install rule
|
|---|
| 2747 | define def_install_src_rule
|
|---|
| 2748 | # the install rule
|
|---|
| 2749 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
|---|
| 2750 | $$(call MSG_INST_FILE,$(srcsrc),$(insdst))
|
|---|
| 2751 | $$(QUIET)$(inscmd)
|
|---|
| 2752 | endef
|
|---|
| 2753 |
|
|---|
| 2754 | ## install one file
|
|---|
| 2755 | define def_install_src
|
|---|
| 2756 |
|
|---|
| 2757 | # deal with '=>' in the source file name.
|
|---|
| 2758 | srcdst := $(subst =>, ,$(src))
|
|---|
| 2759 | srcsrc := $(firstword $(srcdst))
|
|---|
| 2760 | srcdstdir := $(dir $(word 2,$(srcdst)))
|
|---|
| 2761 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
|---|
| 2762 |
|
|---|
| 2763 | # _INSTFUN
|
|---|
| 2764 | ifdef $(srcsrc)_INSTFUN
|
|---|
| 2765 | instfun := $(srcsrc)_INSTFUN
|
|---|
| 2766 | else ifdef $(target)_INSTFUN
|
|---|
| 2767 | instfun := $(target)_INSTFUN
|
|---|
| 2768 | else
|
|---|
| 2769 | instfun := _INSTALL_FILE
|
|---|
| 2770 | endif
|
|---|
| 2771 |
|
|---|
| 2772 | # _INST
|
|---|
| 2773 | ifdef $(srcsrc)_INST
|
|---|
| 2774 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
|---|
| 2775 | else ifdef $(target)_INST
|
|---|
| 2776 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
|---|
| 2777 | else
|
|---|
| 2778 | inst := $(dir $(srcdstdir))
|
|---|
| 2779 | endif
|
|---|
| 2780 |
|
|---|
| 2781 | # calc target
|
|---|
| 2782 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
|---|
| 2783 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
|---|
| 2784 |
|
|---|
| 2785 | # mode, uid and gid
|
|---|
| 2786 | mode := $(firstword \
|
|---|
| 2787 | $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2788 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
|---|
| 2789 | $($(target)_$(srcsrc)_MODE) \
|
|---|
| 2790 | $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2791 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
|---|
| 2792 | $($(target)_$(srcdst)_MODE) \
|
|---|
| 2793 | $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2794 | $($(srcsrc)_MODE.$(bld_trg)) \
|
|---|
| 2795 | $($(srcsrc)_MODE) \
|
|---|
| 2796 | $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2797 | $($(srcdst)_MODE.$(bld_trg)) \
|
|---|
| 2798 | $($(srcdst)_MODE) \
|
|---|
| 2799 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2800 | $($(target)_MODE.$(bld_trg)) \
|
|---|
| 2801 | $($(target)_MODE))
|
|---|
| 2802 | uid := $(firstword \
|
|---|
| 2803 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2804 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
|---|
| 2805 | $($(target)_$(srcsrc)_UID) \
|
|---|
| 2806 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2807 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
|---|
| 2808 | $($(target)_$(srcdst)_UID) \
|
|---|
| 2809 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2810 | $($(srcsrc)_UID.$(bld_trg)) \
|
|---|
| 2811 | $($(srcsrc)_UID) \
|
|---|
| 2812 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2813 | $($(srcdst)_UID.$(bld_trg)) \
|
|---|
| 2814 | $($(srcdst)_UID) \
|
|---|
| 2815 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2816 | $($(target)_UID.$(bld_trg)) \
|
|---|
| 2817 | $($(target)_UID))
|
|---|
| 2818 | gid := $(firstword \
|
|---|
| 2819 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2820 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
|---|
| 2821 | $($(target)_$(srcsrc)_GID) \
|
|---|
| 2822 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2823 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
|---|
| 2824 | $($(target)_$(srcdst)_GID) \
|
|---|
| 2825 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2826 | $($(srcsrc)_GID.$(bld_trg)) \
|
|---|
| 2827 | $($(srcsrc)_GID) \
|
|---|
| 2828 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2829 | $($(srcdst)_GID.$(bld_trg)) \
|
|---|
| 2830 | $($(srcdst)_GID) \
|
|---|
| 2831 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2832 | $($(target)_GID.$(bld_trg)) \
|
|---|
| 2833 | $($(target)_GID))
|
|---|
| 2834 | flags := \
|
|---|
| 2835 | $($(target)_IFFLAGS) \
|
|---|
| 2836 | $($(target)_IFFLAGS.$(bld_trg)) \
|
|---|
| 2837 | $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2838 | $($(srcdst)_IFFLAGS) \
|
|---|
| 2839 | $($(srcdst)_IFFLAGS.$(bld_trg)) \
|
|---|
| 2840 | $($(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2841 | $($(srcsrc)_IFFLAGS) \
|
|---|
| 2842 | $($(srcsrc)_IFFLAGS.$(bld_trg)) \
|
|---|
| 2843 | $($(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2844 | $($(target)_$(srcdst)_IFFLAGS) \
|
|---|
| 2845 | $($(target)_$(srcdst)_IFFLAGS.$(bld_trg)) \
|
|---|
| 2846 | $($(target)_$(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2847 | $($(target)_$(srcsrc)_IFFLAGS) \
|
|---|
| 2848 | $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg)) \
|
|---|
| 2849 | $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2850 |
|
|---|
| 2851 |
|
|---|
| 2852 | # Adjust the source if we got a default PATH. (This must be done this late!)
|
|---|
| 2853 | ifdef $(target)_PATH
|
|---|
| 2854 | srcsrc := $(abspathex $(srcsrc),$($(target)_PATH))
|
|---|
| 2855 | endif
|
|---|
| 2856 |
|
|---|
| 2857 | # create the command
|
|---|
| 2858 | ifdef $(srcsrc)_INSTALLER
|
|---|
| 2859 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
|
|---|
| 2860 | else ifdef $(target)_INSTALLER
|
|---|
| 2861 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
|
|---|
| 2862 | else
|
|---|
| 2863 | inscmd := $$(INSTALL)\
|
|---|
| 2864 | $(if $(uid),-o $(uid))\
|
|---|
| 2865 | $(if $(gid),-g $(gid))\
|
|---|
| 2866 | $(if $(mode),-m $(mode))\
|
|---|
| 2867 | $(flags)\
|
|---|
| 2868 | $(srcsrc) $(insdst)
|
|---|
| 2869 | endif
|
|---|
| 2870 |
|
|---|
| 2871 | # generate the rule (need double evaluation here)
|
|---|
| 2872 | $(eval $(def_install_src_rule))
|
|---|
| 2873 |
|
|---|
| 2874 | INSTARGET_$(target) += $(insdst)
|
|---|
| 2875 | endef
|
|---|
| 2876 |
|
|---|
| 2877 |
|
|---|
| 2878 | ## generate the symlink rule
|
|---|
| 2879 | define def_install_symlink_rule
|
|---|
| 2880 | # the install rule
|
|---|
| 2881 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
|---|
| 2882 | $$(call MSG_INST_SYM,$(insdst),$(symdst))
|
|---|
| 2883 | $$(QUIET)$$(RM) -f $$@
|
|---|
| 2884 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(insdst)
|
|---|
| 2885 | endef
|
|---|
| 2886 |
|
|---|
| 2887 | ## create one symlink
|
|---|
| 2888 | define def_install_symlink
|
|---|
| 2889 |
|
|---|
| 2890 | # deal with '=>' in the source file name.
|
|---|
| 2891 | symdst := $(subst =>, ,$(src))
|
|---|
| 2892 | symlnk := $(firstword $(symdst))
|
|---|
| 2893 | symdst := $(word $(words $(symdst)),$(symdst))
|
|---|
| 2894 |
|
|---|
| 2895 | # _INSTFUN
|
|---|
| 2896 | ifdef $(symlnk)_INSTFUN
|
|---|
| 2897 | instfun := $(symlnk)_INSTFUN
|
|---|
| 2898 | else ifdef $(target)_INSTFUN
|
|---|
| 2899 | instfun := $(target)_INSTFUN
|
|---|
| 2900 | else
|
|---|
| 2901 | instfun := _INSTALL_FILE
|
|---|
| 2902 | endif
|
|---|
| 2903 |
|
|---|
| 2904 | # _INST
|
|---|
| 2905 | ifdef $(symlnk)_INST
|
|---|
| 2906 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
|---|
| 2907 | else ifdef $(target)_INST
|
|---|
| 2908 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
|---|
| 2909 | else
|
|---|
| 2910 | inst := $(dir $(symlnk))
|
|---|
| 2911 | endif
|
|---|
| 2912 |
|
|---|
| 2913 | # calc target
|
|---|
| 2914 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
|---|
| 2915 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
|---|
| 2916 |
|
|---|
| 2917 | # generate the rule (need double evaluation here)
|
|---|
| 2918 | $(eval $(def_install_symlink_rule))
|
|---|
| 2919 |
|
|---|
| 2920 | INSTARGET_$(target) += $(insdst)
|
|---|
| 2921 | endef
|
|---|
| 2922 |
|
|---|
| 2923 |
|
|---|
| 2924 | ## generate the install rule
|
|---|
| 2925 | define def_install_directory_rule
|
|---|
| 2926 | # the install rule
|
|---|
| 2927 | $(insdst):
|
|---|
| 2928 | $$(call MSG_INST_DIR,$(insdst))
|
|---|
| 2929 | $$(QUIET)$$(INSTALL) -d \
|
|---|
| 2930 | $(if $(uid),-o $(uid))\
|
|---|
| 2931 | $(if $(gid),-g $(gid))\
|
|---|
| 2932 | $(if $(mode),-m $(mode))\
|
|---|
| 2933 | $(flags)\
|
|---|
| 2934 | $(insdst)
|
|---|
| 2935 |
|
|---|
| 2936 | .NOTPARALLEL: $(insdst)
|
|---|
| 2937 | endef
|
|---|
| 2938 |
|
|---|
| 2939 |
|
|---|
| 2940 | ## create one directory
|
|---|
| 2941 | define def_install_directory
|
|---|
| 2942 |
|
|---|
| 2943 | # _INST
|
|---|
| 2944 | ifdef $(directory)_INST
|
|---|
| 2945 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
|---|
| 2946 | else ifdef $(target)_INST
|
|---|
| 2947 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
|---|
| 2948 | else
|
|---|
| 2949 | inst := $(PATH_INS)
|
|---|
| 2950 | endif
|
|---|
| 2951 |
|
|---|
| 2952 | mode := $(firstword \
|
|---|
| 2953 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2954 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
|---|
| 2955 | $($(target)_$(directory)_MODE) \
|
|---|
| 2956 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2957 | $($(directory)_MODE.$(bld_trg)) \
|
|---|
| 2958 | $($(directory)_MODE) \
|
|---|
| 2959 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2960 | $($(target)_MODE.$(bld_trg)) \
|
|---|
| 2961 | $($(target)_MODE))
|
|---|
| 2962 | uid := $(firstword \
|
|---|
| 2963 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2964 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
|---|
| 2965 | $($(target)_$(directory)_UID) \
|
|---|
| 2966 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2967 | $($(directory)_UID.$(bld_trg)) \
|
|---|
| 2968 | $($(directory)_UID) \
|
|---|
| 2969 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2970 | $($(target)_UID.$(bld_trg)) \
|
|---|
| 2971 | $($(target)_UID))
|
|---|
| 2972 | gid := $(firstword \
|
|---|
| 2973 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2974 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
|---|
| 2975 | $($(target)_$(directory)_GID) \
|
|---|
| 2976 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2977 | $($(directory)_GID.$(bld_trg)) \
|
|---|
| 2978 | $($(directory)_GID) \
|
|---|
| 2979 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2980 | $($(target)_GID.$(bld_trg)) \
|
|---|
| 2981 | $($(target)_GID))
|
|---|
| 2982 | flags := \
|
|---|
| 2983 | $($(target)_IDFLAGS)\
|
|---|
| 2984 | $($(target)_IDFLAGS.$(bld_trg)) \
|
|---|
| 2985 | $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2986 | $($(directory)_IDFLAGS) \
|
|---|
| 2987 | $($(directory)_IDFLAGS.$(bld_trg)) \
|
|---|
| 2988 | $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
|---|
| 2989 | $($(target)_$(directory)_IDFLAGS) \
|
|---|
| 2990 | $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
|
|---|
| 2991 | $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
|
|---|
| 2992 |
|
|---|
| 2993 | insdst := $(inst)/$(directory)/
|
|---|
| 2994 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
|---|
| 2995 |
|
|---|
| 2996 | # generate the rule (need double evaluation here)
|
|---|
| 2997 | $(eval $(def_install_directory_rule))
|
|---|
| 2998 |
|
|---|
| 2999 | INSTARGET_DIRS_$(target) += $(insdst)
|
|---|
| 3000 | endef
|
|---|
| 3001 |
|
|---|
| 3002 |
|
|---|
| 3003 | ## process one install target.
|
|---|
| 3004 | define def_install
|
|---|
| 3005 | # the basics.
|
|---|
| 3006 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
|---|
| 3007 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
|---|
| 3008 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
|---|
| 3009 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
|---|
| 3010 |
|
|---|
| 3011 | INSTARGET_$(target) := $($(target)_GOALS)
|
|---|
| 3012 | INSTARGET_DIRS_$(target) :=
|
|---|
| 3013 |
|
|---|
| 3014 | $(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)), \
|
|---|
| 3015 | $(eval $(value def_install_directory)))
|
|---|
| 3016 |
|
|---|
| 3017 | $(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)), \
|
|---|
| 3018 | $(eval $(value def_install_src)))
|
|---|
| 3019 |
|
|---|
| 3020 | $(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)), \
|
|---|
| 3021 | $(eval $(value def_install_symlink)))
|
|---|
| 3022 |
|
|---|
| 3023 | # the collection target
|
|---|
| 3024 | TARGET_$(target) := $(PATH_TARGET)/$(target).ins
|
|---|
| 3025 | $(TARGET_$(target)): $(INSTARGET_$(target)) | $(INSTARGET_DIRS_$(target)) $(call DIRDEP,$(PATH_TARGET))
|
|---|
| 3026 | @$(QUIET2)$(APPEND) $@
|
|---|
| 3027 |
|
|---|
| 3028 | $(target): $(TARGET_$(target))
|
|---|
| 3029 |
|
|---|
| 3030 | _INSTALLS += $(TARGET_$(target))
|
|---|
| 3031 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
|---|
| 3032 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
|---|
| 3033 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
|---|
| 3034 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
|---|
| 3035 | endef
|
|---|
| 3036 |
|
|---|
| 3037 | ## process all install targets
|
|---|
| 3038 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
|---|
| 3039 | $(eval $(value def_install)))
|
|---|
| 3040 |
|
|---|
| 3041 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 3042 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 3043 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done install targets)
|
|---|
| 3044 | $(info stat: $(make-stats ))
|
|---|
| 3045 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 3046 | endif
|
|---|
| 3047 |
|
|---|
| 3048 |
|
|---|
| 3049 | #
|
|---|
| 3050 | # PACKING
|
|---|
| 3051 | #
|
|---|
| 3052 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET)) $(PACKING.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
|---|
| 3053 |
|
|---|
| 3054 |
|
|---|
| 3055 | #
|
|---|
| 3056 | # DOCS
|
|---|
| 3057 | #
|
|---|
| 3058 |
|
|---|
| 3059 |
|
|---|
| 3060 | #
|
|---|
| 3061 | # DIRECTORIES
|
|---|
| 3062 | #
|
|---|
| 3063 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES)))
|
|---|
| 3064 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
|---|
| 3065 |
|
|---|
| 3066 |
|
|---|
| 3067 | define def_mkdir_rule
|
|---|
| 3068 | $(directory):
|
|---|
| 3069 | $$(call MSG_MKDIR,$$@)
|
|---|
| 3070 | $$(QUIET)$$(MKDIR) -p $$@
|
|---|
| 3071 | endef
|
|---|
| 3072 |
|
|---|
| 3073 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
|---|
| 3074 |
|
|---|
| 3075 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 3076 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 3077 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done directories)
|
|---|
| 3078 | $(info stat: $(make-stats ))
|
|---|
| 3079 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 3080 | endif
|
|---|
| 3081 |
|
|---|
| 3082 |
|
|---|
| 3083 | #
|
|---|
| 3084 | # NOTHING
|
|---|
| 3085 | #
|
|---|
| 3086 | do-nothing:
|
|---|
| 3087 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 3088 | @$(ECHO) 'prof: $(int-sub $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(nanots ), $(_KBUILD_TS_PREV)) - executing $@'
|
|---|
| 3089 | endif
|
|---|
| 3090 | $(call MSG_NOTHING)
|
|---|
| 3091 |
|
|---|
| 3092 |
|
|---|
| 3093 | #
|
|---|
| 3094 | # CLEAN UP
|
|---|
| 3095 | #
|
|---|
| 3096 | do-clean:
|
|---|
| 3097 | $(call MSG_CLEAN)
|
|---|
| 3098 | $(QUIET)$(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
|---|
| 3099 | $(QUIET)$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $(rsort $(dir $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)))
|
|---|
| 3100 |
|
|---|
| 3101 |
|
|---|
| 3102 |
|
|---|
| 3103 | #
|
|---|
| 3104 | # PASSES (including directory and makefile walking)
|
|---|
| 3105 | #
|
|---|
| 3106 |
|
|---|
| 3107 | ## Subdir
|
|---|
| 3108 | # @param $(pass) Lowercase pass name.
|
|---|
| 3109 | # @param $(PASS) Uppercase pass name.
|
|---|
| 3110 | # @param $(subdir) Subdirectory
|
|---|
| 3111 | # @param $(tag) tag to attach to the rule name.
|
|---|
| 3112 | define def_pass_subdir
|
|---|
| 3113 | pass_$(pass)$(tag):: $(dep)
|
|---|
| 3114 | + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
|---|
| 3115 | endef
|
|---|
| 3116 |
|
|---|
| 3117 | ## Submakefile
|
|---|
| 3118 | # @param $(pass) Lowercase pass name.
|
|---|
| 3119 | # @param $(PASS) Uppercase pass name.
|
|---|
| 3120 | # @param $(makefile) Makefile.
|
|---|
| 3121 | # @param $(tag) tag to attach to the rule name.
|
|---|
| 3122 | define def_pass_makefile
|
|---|
| 3123 | pass_$(pass)$(tag):: $(dep)
|
|---|
| 3124 | + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
|---|
| 3125 | endef
|
|---|
| 3126 |
|
|---|
| 3127 | ## Execute a pass.
|
|---|
| 3128 | # @param $(pass) Lowercase pass name.
|
|---|
| 3129 | # @param $(PASS) Uppercase pass name.
|
|---|
| 3130 | define def_pass_old
|
|---|
| 3131 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
|---|
| 3132 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
|---|
| 3133 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
|---|
| 3134 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
|---|
| 3135 |
|
|---|
| 3136 | $(eval tag:=_before)
|
|---|
| 3137 | $(eval dep:=)
|
|---|
| 3138 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
|---|
| 3139 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
|---|
| 3140 |
|
|---|
| 3141 | $(eval tag:=_after)
|
|---|
| 3142 | $(eval dep:=pass_$(pass)_doit)
|
|---|
| 3143 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
|---|
| 3144 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
|---|
| 3145 |
|
|---|
| 3146 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
|---|
| 3147 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
|---|
| 3148 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
|---|
| 3149 | pass_$(pass)_this: pass_$(pass)_before
|
|---|
| 3150 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
|---|
| 3151 | pass_$(pass)_after:: pass_$(pass)_this
|
|---|
| 3152 | pass_$(pass): pass_$(pass)_after
|
|---|
| 3153 |
|
|---|
| 3154 | endef
|
|---|
| 3155 |
|
|---|
| 3156 | define def_pass
|
|---|
| 3157 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET.$(BUILD_TARGET_ARCH))) )
|
|---|
| 3158 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
|---|
| 3159 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
|---|
| 3160 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
|---|
| 3161 |
|
|---|
| 3162 | $(eval tag:=_before)
|
|---|
| 3163 | $(eval dep:=)
|
|---|
| 3164 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
|---|
| 3165 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
|---|
| 3166 |
|
|---|
| 3167 | $(eval tag:=_after)
|
|---|
| 3168 | $(eval dep:=pass_$(pass)_doit)
|
|---|
| 3169 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
|---|
| 3170 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
|---|
| 3171 |
|
|---|
| 3172 | ifdef KBUILD_SAFE_PARALLEL
|
|---|
| 3173 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
|---|
| 3174 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
|---|
| 3175 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
|---|
| 3176 | pass_$(pass)_this: pass_$(pass)_before
|
|---|
| 3177 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
|---|
| 3178 | pass_$(pass)_after:: pass_$(pass)_this
|
|---|
| 3179 | pass_$(pass): pass_$(pass)_after
|
|---|
| 3180 | else
|
|---|
| 3181 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
|---|
| 3182 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
|---|
| 3183 | pass_$(pass)_doit: pass_$(pass)_before \
|
|---|
| 3184 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
|---|
| 3185 | pass_$(pass): \
|
|---|
| 3186 | pass_$(pass)_before \
|
|---|
| 3187 | pass_$(pass)_doit \
|
|---|
| 3188 | pass_$(pass)_after
|
|---|
| 3189 | endif
|
|---|
| 3190 |
|
|---|
| 3191 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
|---|
| 3192 | endef
|
|---|
| 3193 |
|
|---|
| 3194 | # Generate the defined passes.
|
|---|
| 3195 | $(foreach PASS, $(PASSES), \
|
|---|
| 3196 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
|---|
| 3197 | $(eval $(def_pass)))
|
|---|
| 3198 |
|
|---|
| 3199 | ## Pass order
|
|---|
| 3200 | # @param $(pass) Current pass name.
|
|---|
| 3201 | # @param $(prev_pass) The previous pass name.
|
|---|
| 3202 | define def_pass_order
|
|---|
| 3203 | ifdef KBUILD_SAFE_PARALLEL
|
|---|
| 3204 | .NOTPARALLEL: pass_$(pass)_order
|
|---|
| 3205 | .PHONY: pass_$(pass)_order
|
|---|
| 3206 | pass_$(pass)_order: $(pass_prev)
|
|---|
| 3207 | $$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
|---|
| 3208 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
|---|
| 3209 | else
|
|---|
| 3210 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
|---|
| 3211 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
|---|
| 3212 | pass_$(pass)_banner:
|
|---|
| 3213 | $$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
|---|
| 3214 | pass_$(pass)_order: \
|
|---|
| 3215 | $(pass_prev) \
|
|---|
| 3216 | pass_$(pass)_banner \
|
|---|
| 3217 | pass_$(pass)
|
|---|
| 3218 | endif
|
|---|
| 3219 | $(eval pass_prev := pass_$(pass)_order)
|
|---|
| 3220 | endef
|
|---|
| 3221 |
|
|---|
| 3222 | ## PASS: order
|
|---|
| 3223 | # Use dependencies to ensure correct pass order.
|
|---|
| 3224 | pass_prev :=
|
|---|
| 3225 | $(foreach PASS,$(DEFAULT_PASSES),\
|
|---|
| 3226 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
|---|
| 3227 | $(eval $(def_pass_order)))
|
|---|
| 3228 |
|
|---|
| 3229 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 3230 | _KBUILD_TS_NOW := $(nanots )
|
|---|
| 3231 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done passes)
|
|---|
| 3232 | $(info stat: $(make-stats ))
|
|---|
| 3233 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
|---|
| 3234 | endif
|
|---|
| 3235 |
|
|---|
| 3236 |
|
|---|
| 3237 | #
|
|---|
| 3238 | # THE MAIN RULES
|
|---|
| 3239 | #
|
|---|
| 3240 | all_recursive: $(pass_prev)
|
|---|
| 3241 |
|
|---|
| 3242 | rebuild: clean
|
|---|
| 3243 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
|---|
| 3244 |
|
|---|
| 3245 | # @todo make this a non-default pass!
|
|---|
| 3246 | uninstall:
|
|---|
| 3247 | $(RM) -f $(_INSTALLS_FILES)
|
|---|
| 3248 |
|
|---|
| 3249 | install: pass_installs
|
|---|
| 3250 |
|
|---|
| 3251 | # misc shortcuts.
|
|---|
| 3252 | targets: bldprogs libraries dlls programs sysmods others installs
|
|---|
| 3253 | objects: $(_OBJS)
|
|---|
| 3254 | bldprogs: $(_BLDPROGS)
|
|---|
| 3255 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
|---|
| 3256 | dlls: $(_DLLS)
|
|---|
| 3257 | programs: $(_PROGRAMS)
|
|---|
| 3258 | sysmods: $(_SYSMODS)
|
|---|
| 3259 | others: $(_OTHERS)
|
|---|
| 3260 | installs: $(_INSTALLS) $(_INSTALLS_DIRS) $(_INSTALLS_FILES)
|
|---|
| 3261 |
|
|---|
| 3262 |
|
|---|
| 3263 |
|
|---|
| 3264 | #
|
|---|
| 3265 | # kBuild debugging stuff.
|
|---|
| 3266 | #
|
|---|
| 3267 | show_targets:
|
|---|
| 3268 | @$(foreach target, $(_ALL_TARGETS),\
|
|---|
| 3269 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
|---|
| 3270 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
|---|
| 3271 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
|---|
| 3272 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
|---|
| 3273 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) OBJS_ CLEAN, \
|
|---|
| 3274 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
|---|
| 3275 | $(if $($(target)_$(prop).$(_tmp)),\
|
|---|
| 3276 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
|---|
| 3277 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
|---|
| 3278 | )\
|
|---|
| 3279 | $(foreach prop,$(PROPS_DEFERRED), \
|
|---|
| 3280 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
|---|
| 3281 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
|---|
| 3282 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
|---|
| 3283 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
|---|
| 3284 | ))
|
|---|
| 3285 |
|
|---|
| 3286 |
|
|---|
| 3287 |
|
|---|
| 3288 | #
|
|---|
| 3289 | # Include dependency files.
|
|---|
| 3290 | #
|
|---|
| 3291 | ifneq ($(_DEPFILES),)
|
|---|
| 3292 | includedep $(_DEPFILES)
|
|---|
| 3293 | endif
|
|---|
| 3294 |
|
|---|
| 3295 |
|
|---|
| 3296 | ifdef KBUILD_PROFILE_SELF
|
|---|
| 3297 | _KBUILD_TS_FOOTER_END := $(nanots )
|
|---|
| 3298 | $(info prof: $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_PREV)) - end of footer.kmk)
|
|---|
| 3299 | $(info prof: footer.kmk: $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_FOOTER_START)))
|
|---|
| 3300 | $(info stat: $(make-stats ))
|
|---|
| 3301 | _KBUILD_TS_PREV := $(_KBUILD_TS_FOOTER_END)
|
|---|
| 3302 | endif
|
|---|
| 3303 |
|
|---|
| 3304 | # end-of-file-content
|
|---|
| 3305 | __footer_kmk__ := target
|
|---|
| 3306 | endif # __footer_kmk__
|
|---|
| 3307 |
|
|---|