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