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