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