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