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