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