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